Three Britons are confirmed to have been killed and three more are believed to be dead. Another UK resident is also thought to be dead, Cameron said.
The 22 other Britons caught up in the crisis are now back in the country, Foreign Secretary William Hague said.
A raid by Algerian troops ended a four-day siege at the In Amenas gas facility yesterday. Algeria says at least 23 hostages and 32 militants died.
Algeria's minister of communications said the final death toll might rise.
The Foreign Office said the three confirmed dead included a Briton killed on Wednesday in the initial raid by militants.
Speaking at Chequers, the country residence of the Prime Minister of Britain, Cameron said the attack was a "stark reminder" of the continuing terrorist threat and said he would use Britain's chairmanship of the G8 to ensure that it was at the top of the international agenda.
More From This Section
"This is a global threat and it will require a global response. It will require a response that is about years, even decades, rather than months," he was quoted as saying by the BBC.
"It requires a response that is patient and painstaking, that is tough but also intelligent, but above all has an absolutely iron resolve and that is what we will deliver over these coming years."
Hague said the British survivors had flown back to the UK on government and BP chartered flights overnight and were now being reunited with their families.
The crisis began on Wednesday when militants attacked two buses carrying foreign workers to the remote site in south-eastern Algeria, jointly run by BP, Norway's Statoil and Algeria's state-owned oil company.
The militants then took Algerians and foreign workers hostage at the complex, which was quickly surrounded by the Algerian army.
A statement from the kidnappers said the assault on the gas plant was launched in retaliation for French intervention against Islamist groups in neighbouring Mali.
The hostage-takers belonged to a new Islamist group formed by a veteran Algerian militant and kidnapper, Mokhtar Belmokhtar, who recently broke from al-Qaeda.
Algeria's state news agency APS said 685 Algerian workers and 107 out of 132 foreigners working at the plant had been freed. The nationalities of some of the hostages killed are still not known, but as well as the Britons, US, Norwegian, and Japanese nationals are still missing.