The conventions for punctuating poem titles can seem daunting, but once you master them, you can use the same rules for the titles of books, articles, websites and other publications. Looking at examples of sentences with different syntaxes that all include a poem's title helps to clarify when to use a comma before a poem's title and when to omit the comma.
Position in the Sentence
One way to figure out whether to use a comma is to look at the title's grammatical function in the sentence. When the title of a poem is used as a direct object or as the object of a prepositional phrase, don't place a comma before it. For example, in the sentence "Our class read 'Annabel Lee' when I was in high school," the title is the direct object of the verb "read," and in the sentence "I had to write an essay about 'Annabel Lee' for that class," the title is the object of the preposition "about."
Don't place a comma before the title if the title limits the meaning of the sentence -- that is, if it's used as a restrictive phrase. For instance, in the sentence "Edgar Allan Poe's poem 'Annabel Lee' describes a love that outlasts death," removing the title would change the meaning of the sentence. The statement "Edgar Allan Poe's poem describes a love that outlasts death" needs the title "Annabel Lee" to limit its meaning, since readers would wonder what poem the sentence was talking about.
If the title doesn't limit the meaning of the sentence -- that is, if it's used as a nonrestrictive phrase -- place a comma before it as well as after it. You could remove the title from this sentence and readers would still understand it: "The last poem that Poe ever wrote, 'Annabel Lee,' was completed in 1849." Because "Annabel Lee" equals "the last poem that Poe ever wrote," the title isn't crucial to reader comprehension, and the commas indicate that fact. This use of the poem's title is also called an "appositive," meaning that the title equals or renames another noun phrase in the sentence.
After an Introductory Phrase
Usually, if a title is the subject of the sentence, there's no comma before it: "'Annabel Lee' is my favorite poem." But that changes if the sentence includes any kind of introductory phrase. In that case, a comma follows the introductory phrase and comes before the title. Consider the sentence "In Poe's 'New York Times' obituary, 'Annabel Lee' was included as an example of his work." If you wrote this sentence with standard syntax, it would read, "'Annabel Lee' was included as an example of his work in Poe's 'New York Times' obituary." However, when the prepositional phrase "in Poe's 'New York Times' obituary" appears at the beginning of the sentence instead of at the end, a comma needs to follow it and precede the poem's title.