WASHINGTON — Military leaders are telling commanders to get their troops in line and refrain from misconduct such as urinating on enemy corpses, in a sharp response to the tasteless photos and other disturbing examples of bad behavior that have enraged Afghans and complicated war-fighting.

The broader message to shore up discipline in the ranks was expected to be underscored by Defense Secretary Leon Panetta in remarks today at Fort Benning, Ga.

The Army and Marine Corps chiefs have focused on discipline in recent talks to mid-level commanders around the country. They say they recognize that part of the problem may be leadership stumbles by the young officers who have shouldered much of the burden of wars in Iraq and Afghanistan.

“Maybe we’ve gotten overconfident and maybe we’ve gotten a little bit comfortable in our young leaders,” Gen. Ray Odierno, the Army chief of staff, said Thursday. “Realizing that they are young, they don’t have a lot of experiences. We have to continue to assist them so they understand what is expected of them.”

Marine Corps Commandant Gen. James Amos was blunter.

“We are allowing our standards to erode,” he wrote his commanders. “A number of recent widely publicized incidents have brought discredit on the Marine Corps and reverberated at the strategic level. The undisciplined conduct represented in these incidents threatens to overshadow all our good work and sacrifice.”

Panetta, in his first personal appeal to troops on the issue, planned to remind them that they are representing the American people and that the nation’s greatness lies not in its ships and fighter jets, but the character and standards of its armed forces.

Senior leaders have warned for several years about a deterioration of discipline that may have contributed to increased substance abuse, suicides, domestic abuse and other problems.

Late last year Lt. Gen. Mark Hertling, who now commands U.S. Army Europe, suggested that while only a small percentage of soldiers lack discipline, “If you allow that to go unnoticed, it becomes cancerous.”

In January, Marines were found to have made a video showing them urinating on Afghan insurgents’ corpses. In February, troops mistakenly burned copies of the Quran, which led to violent protests and revenge killings of six Americans.

In March, a U.S. soldier left his base and allegedly killed 17 civilians, mainly women and children. Last month, newly revealed photographs showed U.S. soldiers posing in 2010 with Afghan police holding the severed legs of a suicide bomber.