Newspaper database searches turn up instances in which "light at the end of the tunnel" is used in a literal sense going back to the 1850s. But the earliest figurative sense of the term appears to be this one, from "The Woman Who Was Done," in the St. Louis [Missouri] Republic (July 13 1902):
"Oh, that [Ima Spunge] isn't her real name, but we—the girl who shares the apartment with me and I—call her that. Coz why—she is such a dreadful little sponger. I shan't tell you who she is, for it would be unkind—you might recognize her. But she always leaves me absolutely prostrated after one of her calls. And so we have likewise dubbed the illness which ensues parasitus."
"I begin to have glimmerings of light at the end of the tunnel of mental darkness you've been dragging me through. So she is a parasite?—a kind of pretty, hideous human orchid, feeding on other people. I know one or two myself."
From Father O'Reilly, "St. John's College Appeal," in The Catholic Press, an Australian newspaper (February 24, 1916):
As to the students' library, I am at last able to see light at the end of the tunnel. The Right Rev. Dr. Carroll, Bishop of Lismore, has very generously promised one hundred pounds. And I have received donations of £5 each from the following The Sacred Heart Nuns, Rose Bay; the Sacred Heart pupils, Rose Bay; "a Sydney priest;" Miss Hally, Turramurra; Mster Dick Honnor, Junee; Mr. Neil Macdonald, Neutral Bay. In all, between cash and promises to date, I have rceived for the library £380 out o the £500, which was estimated as needful to make an effective beginning.
And from a letter to the editor of the New Ulm [Minnesota] Review (March 7, 1917), from A.G. Wagner of Kiesling, Washington:
So the day seems to be dawning upon which more people will discern that instead of condemnation and denunciation of those who differ from us, is about to be relegated to the rear and a more wholesome and a more sane concept is to prevail with which the inherent decency and kindly human spirit will manifest unshackled and unrestricted for the peace and happiness of all. "Love's struggle throughout the ages" yet continues, but "there's light at the end of the tunnel," I feel.
This last example is interesting because it puts the "light at the end of the tunnel" saying in quotation marks, as though it were a recognized idiomatic phrase.
Later instances that may have played a major role in popularizing the expression
One later but potentially very important instance of the phrase "the light at the end of the tunnel" in Google Books search results (with regard to popularizing it) is in a paper, "The American Proposal for International Control," presented by Bernard Baruch, and reported in Bulletin of the Atomic Scientists (July 1, 1946):
All of us are consecrated to making an end of gloom and hopelessness. It will not be an easy job. The way is long and thorny, but supremely worth traveling. All of us want to stand erect, with our faces to the sun, instead of being forced to burrow into the earth like rats.
The pattern of salvation must be worked out for all.
The light at the end of the tunnel is dim, but our path seems to grow brighter as we actually begin our journey. We cannot yet light the way to the end. However, we hope the suggestions of my government will be illuminating.
Baruch then went on to quote Abraham Lincoln to the effect that "The fiery trial through which we are passing will light us down in honor or dishonor to the latest generation." Baruch's remarks were evidently widely repeated and discussed. Three years later, as reported in "The Great Inquiry: Testimony at AEC Hearings," in Bulletin of the Atomic Scientists (August–September 1949), David Lilienthal (chairman of the Atomic Energy Commission) offered these remarks in testimony at a senate hearing:
On the 14th of June, 1946, Bernard Baruch, in one of the great state papers of all time, summarized where mankind stood: "The light at the end of the tunnel is dim, but our path seems to grow brighter as we actually begin our journey."
In April of 1947, when the Commission began its work, that dim light at the end of the tunnel was so dim as to be no light at all.
Russia, an Russia only, among the great nations of the earth, has been unwilling to take those steps which might make that dim light brighter.
Baruch's statement of hope about the dim the light at the end of the dangerous tunnel of atomic power (and the development of nuclear weaponry) may have led to widespread use of the saying, including (very famously) U.S. General William Westmoreland's use of the phrase in November 1967 in the context of Vietnam, and less famously (but earlier) in Lyndon Johnson's statement in 1966 to the same effect:
I urge you to remember that Americans often grow impatient when they cannot see light at the end of the tunnel—when policies do not overnight usher in a new order. But politics is not magic. And when some of our fellow citizens despair of the tedium and time necessary to bring change—as, for example, in Viet Nam today‚they are forgetting our own history.