After "extraordinarily constructive" talks, Mr Obama said the aim was to "defeat al-Qaeda" and its allies.
He also pledged greater resources to help civilians in both countries and try to avoid civilian casualties.
Dozens of civilians are thought to have died in US air strikes on Taleban targets in Afghanistan on Tuesday.
Earlier, US Secretary of State Hillary Clinton said she "deeply, deeply" regretted the deaths, adding that the US would work hard to avoid such "loss of innocent life".
Meanwhile, Pakistan's army was engaged in bloody operations to reverse a Taleban advance in its northern provinces on Wednesday.
The bottom line at the summit was more American troops for Afghanistan and more aid for Pakistan, with the Obama administration deepening its involvement in the search for stability, the BBC's Kevin Connolly reports from Washington.
'Solid support'
Mr Obama said Afghan President Hamid Karzai and Pakistani President Asif Ali Zardari fully appreciated the gravity of the security threats posed by militants.
America, he said, was on the side of people in Pakistan and Afghanistan and had a comprehensive strategy for the region, with civilian and military components.
He said the insurgency must be met with a positive programme of growth, so that Pakistanis and Afghans could pursue the possibility of a better life.
President Obama said he expected more setbacks and violence to come, but there was a lasting commitment to defeat al-Qaeda.
The US would, he added, offer unwavering support to the governments of both Pakistan and Afghanistan.
"We have learned time and again that our security is shared," Mr Obama added. "It is a lesson that we learned most painfully on 9/11, and it is a lesson that we will not forget."
Senior US officials have expressed uncertainty over the commitment of the military in Pakistan, a nuclear power, to defeating militants based in its border region.
Speaking earlier after talks with Mrs Clinton, President Asif Ali Zardari said Pakistan would help Afghanistan and the US to fight the threat posed by the Taleban and al-Qaeda.
"For no matter how long it takes and what it takes, democracies will deliver, my democracy will deliver," he told reporters.
"People of Pakistan stand with the people of the United States and the people of Afghanistan."