Actually, I believe McNamara served as an officer in the USAAF during WWII and a couple years afterward. So he had some military experience. He was appointed Secretary of Defense by President Kennedy, who had some military experience himself. Sadly, McNamara was mostly a failure as US SecDef.
Of course, there have been several US Secretaries of Defense that had no military experience.