The president told an audience at Fort Myer, Va., Panetta -- who served as CIA director before taking over at the Pentagon -- was instrumental in ending the war in Iraq, winding down the war in Afghanistan and putting "the core of al-Qaida on the path to defeat."
"Your leadership of the CIA will forever be remembered for the blows that we struck against al-Qaida and perhaps the greatest intelligence success in American history -- delivering justice to Osama bin Laden," he said.
Obama said under Panetta's leadership, the United States is improving medical care for wounded military veterans, "stepping up support for our military families, and doing more than ever to help our newest veterans transition to civilian life -- and that includes the jobs our veterans need as we do some nation-building here at home."
The president praised Panetta for guiding the Defense Department through the transition to allowing openly gay men and women to serve in uniform and for opening combat service to women.
"Because we forged a new defense strategy, we'll be better prepared for the future, better prepared to meet the threats that we face without larger military footprints; better prepared against cyber-attacks; better prepared to advance our interests in the Asia Pacific region; and after more than a decade of war, better prepared for the broadest range of contingencies," he said.
"As our nation's 23rd secretary of defense, every action Leon Panetta has taken, every decision that he has made, has been with one goal in mind: Taking care of our sons and our daughters in uniform, and keeping America safe," Obama said.
Panetta -- who is concluding 50 years of public service during which he served as a member of the House of Representatives, White House chief of staff and director of the White House Office of Management and Budget -- thanked the president and his colleagues, as well as the "brave men and women who are putting their lives on the line every day for this country."
"It's been a hell of a ride for me," the 74-year-old public servant said.
Couple mistakenly served bag of cash at McDonald's drive-thru
Jordana Brewster on Paul Walker: 'He was an enormous presence in my life'