A Google Books search turns up several fairly early descriptions or explanations of "second wind" in a sporting and/or physiological context from as early as 1807. Here are four of them.
From "Replies by Mr. Jackson ["the celebrated scientific Teacher of the Pugilistic Art"], to Some Additional Queries," in John Sinclair, The Code of Health and Longevity; Or, A Concise View, of the Principles Calculated for the Preservation of Health, and the Attainment of Long Life, volume 2 (1807):
A curious fact is, that in [foot] racing, for the first 200 or 300 yards one feels very much distressed, after that a second wind comes, which lasts until one is spent with bodily fatigue.
This quotation from Mr. Jackson also appears in Walter Thom, Pedestrianism; Or, An Account of the Performances of Celebrated Pedestrians During the Last and Present Century (1813).
From "Boxing Match" in The National Register (August 27, 1815):
[Round] 9. Both [Eales and Scroggins] weak, closed, and fell together.
[Round] 10. Eales in the rally cross-buttocked him against the ropes.
[Round] 11. Still high in blood ; Eales tipped his man one in the kidney with the right, and touched his cannister with the left, and ultimately knocked him down.
[Round] 12. Eales's wind short ; met and threw his man in the close.
[Round] 13. Much sparring. Eales fell under very weak.
[Round] 14. Scroggins knocked down his man without ceremony, and got his second wind.
From Richard Lawrence, The Complete Farrier, and British Sportsman, Containing a Systematic Enquiry into the Structure and Animal Economy of the Horse (1816):
The principal distress which hunting horses experience is during the first burst, when the hounds generally run at their greatest speed, but as soon as they begin to sweat, their breathing is relieved by the vessels of the skin becoming relaxed, and allowing a free circulation of the blood from the lungs to the surface of the body. It is prudent, therefore, if possible, to spare a horse until this perspiration takes place, after which, he will be better able to go through the chase than under other circumstances.
It is well known amongst boxers, that they have, what they call, “a second wind” and which is analagous to this second wind in horses, and is obtained in the same way. namely, by sweating. Hence it is generally observed, that they are more distressed for breath at the close of the first two or three rounds, than they are at any other period of the battle. It is true, they become more exhausted in proportion to the duration of the contest, but this is mere exhaustion of muscular power from violent bodily exertion.
And from Pierce Egan, Boxiana; or, Sketches of Antient and Modern Pugilism, volume 2 (1818):
They [Carter and Wood] started [the 2-mile race] at two o'clock, Carter having taken 150 yards in advance. Both of the racers seemed to fly, they got over the ground with such speed, when at the end of the first mile, Wood had made greater progress; but when within a quarter of a mile of the winning post, he was within 20 yards of Carter. The latter had now recovered his second wind, and ran the last quarter of a mile with speed, at the rate of a mile in five minutes, and won by about six yards! It was even betting at starting, but Carter for choice.
An instance of figurative usage of "second wind" appears soon after, in a review of Joseph Lowe, The Present State of England (1822), The Monthly Review, Or, Literary Journal (February 1823):
The war with France began in 1793 ; and though in order to get second wind, as the boxers say, a truce was concluded at Amiens in 1802, which was called a peace, yet, as both parties had obtained glory as well as suffered losses, and as neither was exhausted, they came to the scratch again in 1803,and renewed the conflict with unabated vigor.
The connection between these running, boxing, and horse racing instances of "second wind" and the idiomatic expression we use today seems fairly clear-cut. Christine Ammer, The American Heritage Dictionary of Idioms, volume 2 (2012) offers the following discussion of "second wind":
second wind Restored energy or strength, enabling one to continue an activity or task. For example, I wasn't sure how far they'd get in a week, but now they seem to have gotten their second wind and are making good progress painting the mural. This expression, dating from the late 1800s, was at first (and still is) used for returned ease in breathing after becoming out of breath during physical exertion such as running. It soon began to be applied to nonphysical efforts as well.
Ammer's timing appears to be off by the greater part of a century, but her analysis seems sound.