Early instances of the expression from World War I
The snippet from The New York Times Current History of the European War (1915) cited in Hugo's answer is actually taken from a letter dated October 27, 1914, written by "a cavalry subaltern" in the British army, published in the London Times (November 4, 1914). As Hugo notes, the relevant wording appears in the following paragraph:
Since then we have been doing infantry work in the trenches. We have been out of work in our trenches; only shrapnel and snipers. Some one described this war as "Months of boredom punctuated by moments of terror." It is sad that it is such a bad country for cavalry. Cavalry work here against far superior forces of infantry, like we had the other day, is not good enough. The Germans are dashing good at that house-to-house fighting business.
The instance in Guy's Hospital Gazette (also noted in Hugo's anwer) is actually slightly later than the London Times instance. It takes the form of a letter dated December 1, 1914, from Lieutenant Philip Smith of the 4th Royal Fusiliers, and appears in the issue of December 19, 1914. This instance runs as follows:
We went a few days ago to relieve a regiment in the trenches near here. I went down to take over the dressing station for the M.O. and found Maitland Scott! We in turn were relieved last night by the Gordons and Old Jamie walked in! I have seen quite a lot of him lately and he fairly enjoys this life—the only one whom I have met who does, though I would ten times rather be here than at the base. The best definition I have heard of modern warfare is, "Months of boredom punctuated by moments of extreme terror."
Interestingly, just two years later, an unidentified writer in "The Contributors' Column" in the The Atlantic (October 1916) describes the expression as a cliché:
The Great War has been described as months of boredom punctuated by mo- ments of intense fright.' Ellen La Motte, whom Atlantic readers already know through her 'Under Shell-Fire at Dunkirk' and 'Heroes,' corroborates the underlying truth of this cliché; and her long months of service in a French military field hospital, situated ten kilometres behind the trenches, give her the right to speak with authority.
By then, the Royal Flying Corps had requisitioned a form of the expression to suit its own particular experience, as we see in "Bravery," in C.G. Grey, Tales of the Flying Services: The Adventures and Humours of Aerial Warfare (1916):
One of our bravest men and most efficient officers in the R.F.C. defined air scouting under the conditions which held the armies in Flanders as consisting of "hours of idleness punctuated by moments of intense fear." His meaning was that there was none of the rush and movement of working with an advancing or even a retreating army, which keeps every one busy either moving to a new landing ground or improving the old one. It is simply a matter of killing time for hours waiting to get out on reconnaissance, then succeeds an hour or two hours of the weary round over the enemy's line, with moments when Archibald's attentions become so pressing that aviators are simply and honestly frightened.
Early nonmilitary instances of 'boredom [or idleness] punctuated'
Although the war saying very likely arose extemporaneously from the trenches, without intending to allude to any prior expression of similar form, I note several instances of "idleness [or boredom] punctuated" in the years before World War I.
From "A Bigelow Paper,"in The [London ]Liberty Review (March 1904):
Let one of our readers, like a certain friend of ours, put on a big pot, and offer to everyone who comes along the road a bowl of hot soup. Whether in England or in the Transvaal, in the reign of Edward VII. or the reign of Hammurabi, the certain result in a few weeks would be that twice as many men would shamble along the road as before. It would enter into the calculations of men in Edinburgh, or Cape Town, or Tarsus, as the case might be, when they were considering whether to enter on a course of idleness punctuated with larceny, that they would find encouragement at a certain stage. Yet this is what our Government deliberately does—renders it possible for any number of men, who prefer idleness; and the dissemination of disease and vermin to doing the work which is crying aloud for hands, to wander year by year about the land and prey on the industrious. It is pure ignorance or contempt of first principles that makes people ignore the difference between the possibility and the certainty of being kept in idleness.
From William Le Queux, The Count's Chauffeur: Being the Confessions of George Ewart, Chauffeur to Count Bindo di Ferraris (1907):
The life I led was one of idleness, punctuated by little flirtations, for by Bindo's order I was staying at the Palace as owner of the car, and not as a mere chauffeur. The daughters of Italian countesses and marchionesses, though brought up so strictly, are always eager for flirtation, and therefore as I sat alone at my table in the big salle-à-manger I caught many a glance from black eyes that danced with merry mischievousness.
From a letter from A.W. Goodenough of Norwalk, Ohio, printed in the [New York] Independent (June 6, 1912):
It never occurs to many to do anything but what is customary and conventional, like spending a few weeks in a hotel at a seaside resort. Except in a few external particulars how little life here differs from the ordinary round of fashionable society everywhere. It is the old program—dress, dinner, amusement, cards, dancing, fuss, feathers and silliness—in a word it is boredom punctuated by forced smiles and irrepressible yawns.
And from Ida Evans, "Flesh Under Fleshings," in The Saturday Evening Post (March 28, 1914):
A month later Norman strolled down the street as complacently swagger as the first narcissus of spring. The season had ended the day before, and three weeks of pleasant idleness punctuated by week-ends lay before him. He strolled alone. The four minutes of stage center had not made for loving friendship between him and his associates. They were all peeved except Schmidt, who the next day was taking passage to Paris and was too happy to be conscious of lesser matters.
Assessment
Both the British cavalry subaltern writing in late October 1914 and the British fusilier lieutenant writing in mid-December 1914 refer to the expression as a description or definition that they had heard from someone else. The characterization clearly dates to a fairly early point in World War I, at the latest and very likely probably originated in the British army.
Th nonmilitary instances from 1904–1914, although interesting, seem unlikely to have played any role in the formulation of the military saying—which within a couple of years came to be cited as a cliché, a "classic phrase," an "old definition," a saying invented by "some ancient wit," and "a definition of war which undoubtedly Noah would have regarded as a chestnut."
The expression may indeed accurately described life at the front of many wars—but it did not catch on in published writing until World War I.