As far as I know, until the late Middle Ages/early Renaissance, kings were expected to lead troops into battle or at least be present for major battles. Notably during the Hundred Years’ War, rulers still took the risk of being wounded or captured.
When did it become acceptable to completely “outsource” military command, and where any official justifications provided at the time?
EDIT: Thank you all for your answers. The time frame I was looking for was mostly post-medieval Europe. I was curious if there would have been some kind of backlash or criticism when rulers (in fit fighting condition) stopped showing up to command but I guess public image was not so much of a concern at the time. From what I understand, with the emergence of full-time armies, full-time military commanders would have replaced kings and high nobility on the battlefield and this transition happened progressively.
I'm going to break this down into three related questions, and answer those, because the question mentions both "appearing on a battlefield" and "outsourcing military command" which are two different issues. So (1) When was it ok to be a king or high political leader without also being a high military leader? (2) When was it ok to be a king or high political leader without any military experience? (3) When was it that being a high political leader didn't automatically qualify you as a high military leader?
It depends on what nation you're talking about for the timescale, but all of this analysis generally boils down to five factors: professionalism of the military, distance between the military conflicts and the capital/court, fitness for command, historical precedent (and national culture), and finally there being significant wars to serve in.
But starting off...
(1) When was it ok to be a king or head of state without also being a high military leader?
Pretty much always. In Homer's Iliad (preceding the Odyssey), Agamemnon is portrayed as much more of a political leader than a military leader, let alone a warrior. This is a central theme to his conflict with Achilles. If you want an example that's a bit less mythological, Rome had a number of very powerful politicians and oligarchs who had little military merit. Cicero, for example, is generally considered one of history's great statesmen, and was Consul of Rome. And these trends went forward in time, through the Middle Ages and into the modern era.
There definitely were times and cultures (Mongols, for example) where being a high political leader necessitated high military command. But generally speaking that's a cultural phenomenon, rather than one of historical era.
(2) When was it ok to be a king or high political leader without any military experience?
So, being a high military commander (and hopefully a good one) is quite different from "having military experience at all". Cicero, despite a vast preference for law and the city life, still served two years with the legions to start off his career in politics. Here in the US, some sort of military service is pretty much expected even into the immediate modern era. Clinton, Obama and Trump are all quite unusual in having had no military service (Clinton, noticeably, took action to - legally - avoid his draft), and all have had this brought up during the election cycle. I should mention that almost 1/4 of US presidents did not have military service in their records, though the US in older periods was less involved in military conflict with peer nations. But 1 in 4 is still a fairly small number.
England is a bit of an outlier, as a large number of PM's have had no military experience. This is partially because PM at least began as literally just that: the chief of the Monarch's ministers, and elected from the House of Commons. Until the modern era, the military leadership was more vested in the nobility. However, it is still the case that the military (and police) swear allegiance to the Queen, not the PM, constitution, flag, etc., and royals continue to serve in the military, even if it's not as high commanders. In fact, Prince William (of England) ended his military service as a helicopter pilot in 2013. Prince Charles was a pilot and an officer in the Royal Navy. Queen Elizabeth served as a truck driver and mechanic in an auxiliary women's unit during WWII.
So, arguably, having some military service never went out of style.
(3) When was it that being a high political leader didn't automatically qualify you as a high military leader?
That's more modern, but definitely modern. Even into the 19th century, social/political rank at least partially qualified you for military rank. Depending on the time and place, nations did a better or worse job of making sure that the people with high social rank getting command were actually militarily competent individuals. Louis XIV, for example, was relatively well known for increasing someone's noble rank if they performed particularly well at war; so did Napoleon. In the Red Army it was well known that an officer's political merits often outweighed their military ones, and that in fact over-achieving militarily could by bad for one's health as it made (non-military) political types nervous. Hitler loved to interject himself into military affairs (often, thankfully, to Germany's detriment).
Being in a war for national survival was another major factor that helped transition to a more professional military, but huge (or at least very publicized) disasters did their part to. The Royal Navy seemed to have a better reputation for professionalism than the Army during the Napoleonic Wars, and I'd argue part of that was due to Britain's ships serving as the nation's most critical line of defense. For England I'd really point to the Crimean War's Charge of the Light Brigade starting the process, and massive losses by ham-handed commanders in WWI for really putting the nail in the idea of a sort of privilege to command.
That said, I'll commit a sin and share an anecdote. When I was a kid, I went to British boarding school, where there was a year of compulsory military cadet training (I missed it because my family moved back to the US). It was explained to me (true or not), that part of this training was so that in the event of a war there would be a legitimate reason for our privileged, well educated, upper-class school members to get officer training and positions, rather than entering in with the enlisted. So, to an extent, there is still a degree of military preference attached to social position. I should emphasis on the other hand that being an officer is hardly exclusive nowadays, and promotion beyond that is definitely by merit.
With all that said, the President is still the Commander-in-Chief, the PM functions as such, as does every other true head of state. So, when you hit the highest position, you have control. Given modern communications, that can be for better or worse. It was noted in the Vietnam War that authorization for relatively tactical military operations sometimes went much higher than it perhaps should have, even up to the White House. Currently, the US operates a drone strike force where again decisions are at a high political rather than military level. So in some ways, that's something that never really ended either, though the extent to which the King (or President) can just hand out commands to friends and family is definitely much more limited.
And, if you go somewhere like Saudi Arabia, nepotism in the military is still very much alive and well.
So, I hope that helped answer the question (it's a pretty broad subject, every nation, every era...). It's also worth mentioning that typically we remember leaders who were also great military commanders or conquerors. Wars always make their way into history. And people looking to make their way into history often start (or get involved in) wars. So there's definitely an element of perceptual bias. But overall, I'd say that modernization in the 20th century put paid to social-ranked implications for high military command, but that military service is still expected for those seeking the highest authority.