The line "for whom the bell tolls" is in a poem by John Donne, a poet who lived during the 16th and 17th centuries. Ernest Hemingway had his famous book of the same name published in 1940, so he would have gotten the title from Donne. The heavy metal band Metallica also pays tribute to the phrase with a literary adaptation that has long been considered a fan favorite.
The poem is only 14 lines long, and the memorable line come just before the last. Donne was the dean of St. Paul's Cathedral in London and the line was actually taken from one of his sermons, "Meditation 17, Devotions upon Emergent Occasions."