Speaking at the University of Louisville in Kentucky, Panetta said the United States has considerably weakened al-Qaida and decimated its leadership, the Defense Department reported on its Web site.
"Let me be very clear," Panetta told the students about the killing of coalition forces by Afghans. "The brutal attacks that we have seen on our troops in the last few days will not change or alter our determination to see this through.
"We have demonstrated that we will continue to do everything possible to protect our citizens and our security," he said.
"Our goal is that by the end of 2014, the Afghans will have the responsibility to govern and secure themselves," he said.
Panetta said the United States must maintain the world's strongest military while maintaining effective diplomacy and building a strong economy.
"At the same time, we face an additional threat to our national security which must also be confronted, and that is long-term debt and high deficits," he said.
He said the American force will be smaller but will be more agile and ready to deploy anywhere in the world and win.
"We are going to maintain and even enhance our presence in vital regions of the world like the Middle East and the Asia-Pacific region," Panetta said.
Panetta stressed the need to build defenses against any major cyberattack.
"We are literally getting hundreds or thousands of attacks every day that try to exploit information in various [U.S.] agencies or departments," Panetta said.
Martin Bashir resigns from MSNBC over Sarah Palin comments
Ron Burgundy interviews Peyton Manning on SportsCenter