My understanding, after reading everything I could get my hands on, is if you want credit for it, record it, write down the lyrics, and send the tape and lyrics to the Library of Congress with the appropriate forms. Sooner is better.
Technically, as soon as you've recorded an original, it's copyrighted, but that can be beastly to prove in the event somebody steals it. I also have saved all the rough drafts of everything I've written (what a mess!) so I should be able to show how the piece evolved.