Cameron succeeds James Cleverly, who has replaced Suella Braverman as the new home secretary. Braverman came under fire over her immigration policies and her criticism of police actions at recent demonstrations.
The government said Cameron will be appointed to the House of Lords, Parliament's upper chamber. Cameron led the British government between 2010 and 2016.
He resigned after the country voted to leave the European Union (EU) in a referendum. Cameron said Britain was "facing a daunting set of international challenges."
Hundreds of thousands of people rallied in London to demand a ceasefire in Gaza in the largest demonstration in support of Palestine in the UK and one of the largest in British political history �� pic.twitter.com/vFLpTm1qSm
"While I have been out of front-line politics for the last seven years, I hope that my experience -- as Conservative leader for 11 years and prime minister for six -- will assist me in helping the prime minister to meet these vital challenges," he said in a statement following the appointment.
Professor Iain Begg from the London School of Economics and Political Science (LSE) described Cameron's appointment as "bold, puzzling and sensational."
"It's certainly a surprise that Rishi Sunak should decide to bring back one of his predecessors, David Cameron, as foreign secretary," he said, adding that "This is clearly an attempt to bring in serious experience at top of government."
Downing Street said Jeremy Hunt will keep his role as chancellor of the exchequer. Monday's reshuffle came months ahead of Britain's next general election, which must be held by January 2025 at the latest.
Begg said Sunak wants to reboot his government "in a way that's going to appeal to the British electorate in view of a general election due in the next year or so, possibly even as soon as May."