Panetta said the surge had accomplished its mission, which was beating back the Taliban to give the Afghan government and its security forces the time and space to take hold.
But after a tumultuous week in Afghanistan that saw commanders put limits on when NATO and Afghan troops can patrol together, Panetta said there will still be difficult days ahead.
Recently, there have been more attacks in which Afghan Army and police troops, or insurgents dressed in their uniforms, have been turning their guns on U.S. and NATO forces. That has shaken the trust between the allied troops and the Afghans they were there to train.
The withdrawal, which was completed on schedule, still leaves close to 100,000 NATO troops in Afghanistan, including 68,000 Americans.
The Associated Press contributed to this report.