@tanguatlay,
Well, in reading this more carefully, I think either would work depending on the subtlety of meaning and context:
I read "poem" in the first sentence as a noun used as an adjective modifying the title--truth is, the title should be in italics and the word should be "book," but that's another matter.
The second sentence could also have "poem" as a noun modifying the title and not need the commas at all.
It's a subtle difference. With the commas, the title is an appositive restating and further clarifying the subject of the sentence "poem." Without the commas, "The Giving Tree" becomes the subject of the verb "was," and "poem" becomes a noun modifying the title (which should be book with the title in italics, not quotation marks).
And now that I really think about it, as a stand-alone sentence without any further context, I prefer the second sentence without the commas.
But since you have that sentence following another about the teacher, then I think you do need to have it separated by commas as an appositive.
The teacher opened the book and selected a poem. The poem, "The Giving Tree," was later adapted as a puppet show.
The second time you use "poem" you are referring to the previous occurrence of the use of the word, that is, the poem that was selected by the teacher. By using the appositive, you are further clarifying which poem the teacher selected as opposed to all the other poems out there.
If you had this as a stand-alone sentence, then commas would not be necessary, since there would be no need to distinguish the poem selected to be read by the teacher from all the other poems in the world.
Also, if you had an entire essay evaluating, explicating, and referring to a lot of different poems and by the time you got to this statement about "The Giving Tree" it might be entirely unclear to the reader as to which poem you were referring, then using the appositive with commas surrounding the title might be in order. And using the appositive would emphasize the title to the reader.