Speaking at the end of the G8 summit in Northern Ireland, Cameron said leaders had discussed the issue during a dinner last night during which they focused on foreign policy.
"I think this is the right thing to do, of course it involves all sorts of difficulties," Cameron told a news conference at the summit on the edge of a lake in the luxury Lough Erne golf resort.
Cameron said the security response in Afghanistan, where Britain still has around 7,900 troops and is in the process of handing over to Afghan security forces, had to be matched by a "political process."
"And we've been fully engaged and involved in this process right from the start, indeed from the moment I became prime minister."
Also Read
Washington announced the talks "in a couple of days" in Doha as the Taliban said they had opened an office there to oversee peace talks.
Cameron highlighted the similarities between the situation in Afghanistan and Northern Ireland, where a 1998 peace accord largely ended decades of Protestant-Catholic violence.
"That shouldn't signal any weakening of our security response, it absolutely doesn't, but if we can persuade people there is a legitimate political path for them to follow we should do so.