to answer your question:
you should agree on some kind license with the client.
it would not protect the code though, but you would have proper legal grounds
if they use it for something else.
however, my personal note on stuff like this:
any project i do, i assume the code (or part of it) can be re-used elsewhere, and frankly i take it as a compliment if they reuse it.
i get paid to do a specific project, and what they are doing with whatever i produced is up to them.
software development are driven by innovation and forcing people to re-invent the wheel is just bad for all of us, and gives us s**t like software patents.
so, my advice would be:
get the client to agree on a license, but assume that it the project or parts of it will be re-used, but thats part of life (and software development)
its better to invest your energy in learning more stuff and building good relations with clients; that way you will surely get other projects and be a happier person than trying to protect your code and hunt down those that re-use your code (which frankly, will be a battle you will never win)
i have had several projects where clients have come back to me and started a conversation like:
"hey, we took the code you did at XXXXX and tried adapt it to be used in YYYYYY. works excellent, but now we want to do ZZZZZZ as well, can you take on that project?"
i doubt they would get back to me if i had forced them to agree to not re-use the code;
they would probably re-used the code anyway but gotten in touch with another developer to do the new development to make sure i would not find out that they re-used it.....
just my 2 cents and philosophy about this topic, seems to work for me so far.