President Hamid Karzai and his Pakistani counterpart Asif Ali Zardari also urged the Islamists to join the reconciliation process in Afghanistan.
But with neither the Taliban nor the United States at the talks, and the militants still refusing to talk to Kabul, analysts said the commitment by the three leaders risked being one-sided.
They had a private dinner on Sunday and then full talks on Monday at Cameron's Chequers country retreat near London, amid growing fears that a civil war could erupt when international troops leave Afghanistan in 2014.
"All sides agreed on the urgency of this work and committed themselves to take all necessary measures to achieve the goal of a peace settlement over the next six months," they said in a joint statement issued by Cameron's office.
"They supported the opening of an office in Doha for the purpose of negotiations between the Taliban and the High Peace Council of Afghanistan as part of an Afghan-led peace process," the statement said.
Karzai had previously shunned the idea of a Taliban office in the Qatari capital because of fears that it would lead to the Kabul government being frozen out of talks between the United States and the Taliban.
The joint statement also said that the Afghan and Pakistani leaders had agreed arrangements to "strengthen coordination" of the release of Taliban detainees from Pakistani custody.
Afghan peace negotiators have welcomed Pakistan's release of dozens of Taliban prisoners in recent months, a move they believe could help bring militants to the negotiating table.
There was no immediate reaction from the Taliban.
The summit was the third trilateral meeting in a year following meetings in Kabul last July and New York in September - but the first in which Pakistani and Afghan army and intelligence chiefs took part.
Cameron, whose country is the second biggest contributor of troops to Afghanistan with 9,000 still based there, appealed directly to the Taliban to join the reconciliation process.
"Now is the time for everyone to participate in a peaceful political process in Afghanistan," he told a press conference after the talks.
Karzai told the press conference he hoped in future to have "very close, brotherly and good neighbourly" relations with Pakistan, which has been regularly accused by both Kabul and Washington of helping to destabilise Afghanistan.
Support from Pakistan, which backed Afghanistan's 1996-2001 Taliban regime, is seen as crucial to peace after NATO troops depart - but relations between the neighbours remain uneasy despite some recent improvements.
Zardari said it was in Islamabad's interests to support the initiative.
"Peace in Afghanistan is peace in Pakistan. We feel that we can only survive together," he said. "We cannot change our neighbourhood or our neighbours."
Pakistani political and security analyst Hasan Askari dismissed as "too ambitious" the prospect of securing in six months a settlement to end more than 11 years of war.
The lack of Taliban involvement in the talks was a particular problem, he said.
In March last year, the Taliban suspended contacts with US representatives in Qatar over a potential prisoner exchange and opening of a liaison office in the Gulf state, and publicly refused to negotiate with Kabul.
Asked whether a peace deal was possible in six months, Askari told AFP: "I don't expect that, it would be a major upset of the calculation."
Meanwhile, the International Monetary Fund said it had reached an agreement with Afghanistan on the path to financial reforms needed if the war-ravaged country is to unlock its next aid installment.
The IMF granted Afghanistan a $133.6 million line of credit in November 2011 but has so far handed out just two installments of around $18 million each.
Afghan authorities have agreed on the need to tighten monetary policy, the IMF said.
The United States also suspended its blacklisting of the Afghan airline Kam Air on Monday, after Karzai's government promised an investigation into claims of opium trafficking by the company.
90% of the world's opium is produced is Afghanistan, according to the UN Office on Drugs and Crime (UNODC).