His comments came after pictures emerged showing US soldiers posing with the mangled remains of suspected suicide bombers.
The photos come at a particularly sensitive moment in US-Afghan ties.
In March, 17 Afghan civilians - including nine children - were massacred in the southern Kandahar province. US staff Sgt Robert Bales was later charged with 17 counts of premeditated murder.
The Taliban called off peace talks in the wake of the deadly rampage and threatened more attacks.
In February, thousands of Afghans held street rallies after US soldiers inadvertently burned copies of the Koran at a Nato base in Kabul.
More than 30 people died in the ensuing unrest, as people protested at US bases and diplomatic missions.
A month earlier, a video emerged apparently showing US marines urinating on dead Afghans.
The Americans are now finding themselves on the backfoot after these incidents, the BBC's Paul Adams in Washington says.
"Secretary Panetta strongly rejects the conduct depicted in these two-year-old photographs," his spokesman George Little said in a statement on Wednesday.
Previous tension points
- March 2012: US staff Sgt Robert Bales accused of killing 17 Afghan civilians
- February 2012: Deadly protests after US troops inadvertently burn Koran
- January 2012: Video shows US marines urinating on dead Afghans
- March 2011: Radical US pastor burns Koran, triggering deadly protests
- April 2008: Protests against cartoon of Prophet Muhammad in Danish newspapers
The commander of the International Security Assistance Force in Afghanistan (Isaf), Gen John Allen, also condemned the actions of the soldiers, while the US Ambassador to Afghanistan, Ryan Crocker, them as "morally repugnant".
Mr Crocker said they "dishonour the sacrifices of hundreds of thousands of US soldiers and civilians who have served with distinction in Afghanistan".
The pictures - published in the Los Angeles Times newspaper - apparently show soldiers from the 82nd Airborne Division posing with remains of suspected suicide bombers in Afghanistan's eastern Zabul province.
Some are seen grinning next to the bodies, while others are seen holding one of the corpse's severed legs.
Another set of photos - from a few months later - apparently shows soldiers from the same division holding a dead man's hand with the middle finger raised.
The Los Angeles Times only published two of 18 photos.
It said pictures had been given by a US soldier "to draw attention to the safety risk of a breakdown in leadership and discipline" among American troops.
The depicted soldiers - who have not been identified - had seen friends killed or wounded in suicide and other bomb attacks in the course of their year-long deployment, the paper said.
And it defended its decision to publish the photos, despite a prior request from the US military not to do so.
"After careful consideration, we decided that publishing a small but representative selection of the photos would fulfil our obligation to readers to report vigorously and impartially on all aspects of the American mission in Afghanistan, including the allegation," the paper's editor Davan Maharaj said.