In the U.S., you can register your copyright at any time but there are advantages to doing so within five years after first publication.
The U.S. Copyright Office says:
"Why should I register my work if copyright protection is automatic?
Registration is recommended for a number of reasons. Many choose to register their works because they wish to have the facts of their copyright on the public record and have a certificate of registration. Registered works may be eligible for statutory damages and attorney's fees in successful litigation. Finally, if registration occurs within 5 years of publication, it is considered prima facie evidence in a court of law. See Circular 1, Copyright Basics, section “Copyright Registration” and Circular 38b, Highlights of Copyright Amendments Contained in the Uruguay Round Agreements Act (URAA), on non-U.S. works."