There's a difference between custom-made software and "off-the-shelf" products.
If I buy Microsoft Office:
I only buy a licence to use it
I don't get access to the source
The whole thing costs me a few hundred dollars.
If I commission a team of programmers to write an office suite with similar functionality from scratch:
I own the software
I own the source
The whole thing costs me many millions of dollars
A good rule of thumb is that if you are paid to develop software, then whoever pays you owns the software.
However, you and your customer can agree different terms if you like. For instance:
you might offer to do the work for less if they don't get the source and have to go to you for any enhancements.
(If the customer agrees to this, he is an idiot. He's fu*ked if you get run over by a bus)
you might offer to do the work for less if you retain the rights to the product so that you can sell it again and agin to other customers - but your customer can also do what he likes with source
(much better for everyone)
Regards,
Jack