Well, it's not legal if you deliberately steal the title of a song because that...probably comes under plagiarism or something. Passing someone else's words off as your own.
However I believe it is legal to quote from lyrics, which is what I was referring to.
It's absolutely not legal to quote song lyrics, ever, without permission (usually paid, and hefty payments at that), anywhere. Even if you credit the author.
Titles can't be copyrighted -- blacbird's example is a great one -- and you can use song titles in your book (best to make sure you credit the band, such as: "Enter Sandman", by Metallica, was playing on the radio while Jim chased Susan).
Using someone else's lyrics in your writing is a sure-fired way to say, a) I'm a NEWBIE! and I know nothing about this industry, and b) Sue me, sue me, sue me!
And, as someone else said, they're getting iffy about some titles. Steely Dan brought suit against the film company that produced "You, Me and Dupree", claiming it was too close to their song "Cousin Dupree". I don't believe they won, but if a band goes up against little ol' you or little ol' me, they have a great chance of winning simply because they can afford the legal fees. Do yourself a favor...don't go there.