There's a good reason why the US President is called Commander-in-Chief. Just as the nation's founders were careful to establish a separation of powers between the executive, legislative and judicial branches of government, thereby creating a system of checks and balances among the branches, so too did the founders recognize the importance of civilian oversight as a check on the military mindset.
Top officers from the Army, Navy, Air Force, and Marines form the Joint Chiefs of Staff, which in turn advise the President on military matters. But the President, a civilian (though often having served in the military) is the supreme commander. Period. There has always been a love/hate relationship between the two. The military tends to perceive civilians as ignorant of tactical and strategic needs, while civilians tend to regard the military as overly-prone to plunge into armed engagement (akin to the maxim "If your only tool is a hammer, you will tend to see every problem as a nail"). This inherent tension has sometimes boiled over, as it famously did in 1951 when President Harry S. Truman relieved General Douglas MacArthur of his command, after MacArthur made scathing public remarks which were critical of Truman.
It is an open question whether history is about to repeat itself. General Stanley A. McChrystal, the top commander in the Afghanistan war, has been summoned to Washington to meet with President Barack Obama, to explain remarks which McChrystal and his staff made on several occasions to a Rolling Stone reporter -- derisive remarks expressing open contempt toward senior members of the Administration. One observer notes that McChrystal overstepped the bounds of propriety so severely that his behavior amounts to gross insubordination, and that his being fired should be automatic. Anything less would make the President look like a weak leader, at a time when the decisive quality of his leadership is already in question in light of the Administration's slow response to the Gulf oil disaster.
I'm inclined to agree with this assessment. What in the world was McChrystal thinking? The Rolling Stone remarks happened not merely in formal briefings, but also in bars and other off-duty settings. Embedded journalism is one thing (and a dubious concept at that). McChrystal's poor judgment and poor impulse control are not qualities I would want in my commanding officer, if I were a soldier in the field.
On a deeper level, my own feeling is that we shouldn't be in either Iraq or Afghanistan to begin with. It has been proven over and over, particularly in the context of counterinsurgency, that the standard military model is a failure. We are far more effective in winning friends and allies when we invest time, effort and financial support toward building infrastructure -- roads, water supply, sewers, power grids, telecommunications, and most critically, education. Greg Mortenson of the non-profit Central Asia Institute has written two books, Three Cups of Tea and Stones into Schools, which describe his success in building schools in remote villages in Pakistan and Afghanistan, with special emphasis on educating girls. He has found over and over that "if you teach a boy, you educate an individual, but if you teach a girl, you educate a community." His work has had a measurable impact -- the dozens of villages in which he as worked are much less likely to support the Taliban. This is a sharp contrast to US military presence being seen by locals as an invasion by power-hungry infidels, creating many more terrorists than are rooted out through armed conflict.