Basically, this is how I see it...when you write code on your own time, like a class, etc and release it as (L)GPL or whatever, that code falls under that license.
If you write code for someone else, you'd better have written permission to release that code as GPL, etc or obviously, if they pay you for it, it's theirs exclusively.
If you ever plan on using open source or existing code in any projects (as a whole, not segments) it would be wise to likely inform your client/employer why you want to use open source and how it will benefit them.
I like to think most companies are cool with you releasing some code as open source, just explain to them why it's a good candidate for open source and that your not releasing their core application functionality as open source. It's the core work most companies are interested in anyways.
Anyways, I would suggest getting "written" permission to use or release any code you write as open source when working for a client. If you write it on your own time, obviously it's yours, but you should still inform your client if you plan on using some code you wrote (even if it's not released under existing open source licenses) in their products, making it clear, it's perpetually free to them, to do whatever they they wish, however it is not theirs exclusively.
It really depends on agreement you and your client strike up...
I recently had an agreement where I developed a minimal CMS and licensed it to them, it was not *sold* to them. They are basically restricted to the same EULA as when using a desktop application, but they paid for the majority of the development. In this way it's sort of analogous to customizing open source software.
You develop a bare bones application. Someone finds it useful and they start using it. A little while later, they want changes, so they hire you to implement those changes. Those changes are optionally refactored into the core application. Yes, they pay for your time and the changes are made available to the general public (or at least your current client base) but that's open source for you. If they want changes to be made exclusively to them, you double your hourly rate

Explaining the reason is because they are hindering the open source movement by keeping anything proprietary. When faced with a rate hike like that, I Imagine most businesses would see the usefulness in open source software development.
Cheers
