Other posters have already said that legally it all depends on the license you work out with the customer, and they are correct.
Having said that, I find that the customer's expectations will depend on what the financing model for the product was. Typically when you get paid for software, it will have been developed under one of two models:
- My company does the product development on with its own money, and then sells the finished product to multiple customers. Examples are products like Microsoft Office or Adobe CS4. Typically customers assume that they're paying for just a license of the product, since they weren't involved in the actual creation of the code itself at all.
- The customer has a specific need it needs to address, and hires and pays my company to develop software to address it. Most of the consultant arms of major software vendors operate this way; for example, OPNET (which makes a product called Modeler popularly used in simulating communication networks) develops some protocol models for Modeler this way. As the customer is directly involved in directly funding the development (often billing will involve paying for actual developer-hours, and is typically much more expensive than licensing an existing product), they'll usually expect to get the rights to the code as well.
If you're using one of the above approaches but want your licensing to work differently, the key is to make this clear to the customer up-front (managing expectations isn't something techies typically enjoy spending time doing, but it's a very important part of having a successful business relationship with your customer) and make sure all your legal wording is done correctly as well. I've worked at companies before where product development was funded by customers, but the need the customer wanted addressed was sufficiently general that the company wanted to retain the copyright and IP to resell to others. In this case, the customer was granted cheap or free perpetual licenses to use the software that was developed, but the contract was written so that the company retained the copyright and the right to sell licenses to others as well.