"If you talk to General Petraeus, I think he would argue that part of the success in Iraq involved reaching out to people that we would consider to be Islamic fundamentalists, but who were willing to work with us," Obama said.
"There may be some comparable opportunities in Afghanistan and the Pakistani region," he said. "But the situation in Afghanistan is, if anything, more complex."
Obama had suggested before becoming president that he was open to talks with more moderate Taliban leaders.
Meanwhile, Iran has said that it is willing to consider taking part in a meeting with the US to look at finding a solution for stability in neighbouring Afghanistan.
"If America and European countries and others need to use Iran, they should give us [the invitation]," Gholam-Hossein Elham, an Iranian government spokesman, said in a news conference on Saturday.
Hillary Clinton, the US secretary of state, proposed a high level international conference on Afghanistan during a Nato gathering earlier last week.
Clinton said that a meeting should take place before the end of the month.
Elham said that his country's interest in attending any conference would be "to help Afghanistan."
"For us, Afghanistan is very important. Afghanistan's security is our security, Afghanistan's progress is our progress and Afghanistan's stability is ours," Elham said.
Iran would be invited as a neighbour of Afghanistan, Clinton said.
Obama last month approved the deployment of 17,000 more troops to Afghanistan as part of an effort to stabilise the country.
Violence is at its highest in Afghanistan since US-led forces toppled the Taliban in late 2001.
Obama, who sees the Afghan conflict as a more pressing concern than the unpopular war in Iraq, is trying to convince other Nato nations to boost troop commitments to the international operation.