You must register your copyright with the U.S. Copyright Office before you are legally permitted to bring a lawsuit to enforce it.
You can register a copyright at any time, but registering it promptly may pay off in the long run. "Timely registration" -- that is, registration within three months of the work's publication date or before any copyright infringement actually begins -- makes it much easier to sue and recover money from an infringer. Specifically, timely registration creates a legal presumption that your copyright is valid, and allows you to recover up to $150,000 (and possibly lawyer fees) without having to prove any actual monetary harm.