In ancient and medieval times, the nobility often formed elite forces of heavy cavalry or other troops. When these formations suffered massive casualties, how would a country replenish it's stock of nobility faster than new noble sons were born and trained? Was it just a question of time or would non-nobility be elevated in status?
This depends a lot on time and place and there are a lot of factors. I'll answer for medieval and early modern Europe, primarily England.
Firstly is the fact that truly important nobles wouldn't often be at the front lines. People with titles were often sent as generals or commanders to organize the military operations but not to fight themselves. In fact, many kings and queens chose to fight their wars with hired mercenaries combined with conscripted countrymen. A few members of the nobility would be nominally in charge for diplomatic negotiations and planning, but they sometimes weren't even in charge of the military aspects of the war. (See Elizabeth's I very different dealings with John Casimir and the Duke of Leicester during various wars with Spain in the Netherlands, just as an example.)
But you are correct that members of the nobility did sometimes die in battle or from disease in the ranks. The Duke of Leicester's nephew and successor as Elizabeth's favorite, the Earl of Essex, saw his own brother die in one of his own military operations. The numbers of noble deaths paled in comparison to the deaths of commoners in these wars, however, which could be to the tune of 10,000-12,000 deaths. The English and European aristocracies simply could not sustain that number of nobles, let alone that number of nobles being sent to war while keeping the court, their estates, and governing the country running as well.
When important people did die, they were replaced by relatives, sometimes very distant relatives. Entire cadet branches of noble families that had been untitled for years would sometimes be resurrected because of the convenient inheritance of a title. But these weren't creating a new class of nobility - they had noble blood anyway and their positions were simply elevated.
There was a system of monarchs bestowing new "creations" of extinct titles on their favorites. These people were usually of at least distantly noble stock but provided lifeblood to the aristocracy. Elizabeth I was particularly stingy about creating titles; several died out during her reign and were not given a new creation, meaning that there were actually fewer extant titles at the end of her reign than at the beginning. To your point, however, there was a system in place for elevating a new class of noble elite in the case of a significant quantity of titles dying out through war or disease.
Source for details about Elizabeth's reign:
Elizabeth by Anne Somerset