Let's say you have a team building a decent game and all is well technically and people-wise. You feel pretty sure you'll get to a product that can be sold. How does an indie studio (with good practices in this domain) typically manage the IP, esp. trademarking and copyrighting? When's the right time to do this, early or later?
First get yourself a copy of Business and Legal Primer for Game Development. It is an invaluable resource, not just in the legal department. They have a chapter or two on this sort of thing, and it's comprehensive.
If you're in any doubt about the status of things or who will claim ownership, I'd do what Josh Petrie suggests, and right away.
Hire a lawyer. The earlier the better -- you should have done it already to draw up contracts concerning who retains what IP if people leave or disagree, et cetera.
See this article on the legal issues related to ad hoc, indie development teams (written by a real lawyer, which I am not, so my advice is not legal advice).