He was speaking in a CBS interview, as the White House prepares to unveil a comprehensive strategy for Afghanistan.
Mr Obama said preventing attacks against the US remained its "central mission" in Afghan operations.
Earlier, the US envoy to Afghanistan and Pakistan said US policy would no longer treat the two separately.
Richard Holbrooke, the US special envoy to Afghanistan and Pakistan, told the BBC: "In the past, the United States government stove-piped it, they had an Afghan policy and a Pakistan policy. We have to integrate the two and I hope the rest of the world will join us in that effort."
Mr Holbrooke said Taleban sanctuaries in Pakistan's tribal areas along the Afghan border were the primary problem for Kabul.
He also said that the era of "neglect" of the region was over, promising more troops and resources.
'Effective strategy'
"What we're looking for is a comprehensive strategy [for Afghanistan]," President Obama told the CBS programme 60 Minutes on Sunday.
"Threre's got to be an exit strategy. There's got to be a sense that this is not a perpetual drift."
Mr Obama - who last month ordered the deployment of additional 17,000 US troops to Afghanistan - acknowledged that military force alone would not be enough to achieve Washington's objectives, which included the defeat of Taleban and al-Qaeda militants.
He said an effective strategy could include building up economic capacity in Afghanistan and improving diplomatic ties with Pakistan and other regional players.
But Mr Obama stressed that Washington "can't lose sight of what our central mission is".
"Making sure that al-Qaeda cannot attack the US homeland and US interests and our allies. That's our number one priority."
He said the central task was the same as when US troops went into Afghanistan after the 11 September 2001 attacks.
Bonus row
In the same interview, Mr Obama expressed doubts about a recent bill in Congress to impose punitive taxes on bonuses at companies that have been bailed out by government money.
The lawmakers' move followed outrage over the decision by AIG insurer to award its employees $165m (£113m) in bonuses after taking $170bn in aid from the government.
But Mr Obama questioned whether such a measure would be legal and constitutional.
He stressed that it was important to focus on the bigger picture of rescuing the US economy.
"We can't govern out of anger. We've got to try to make good decisions based on the facts in order to put people back to work, to get credit flowing again.
"And I'm not going to be distracted by what's happening day-to-day, I've got to stay focused on making sure that we're getting this economy moving again," Mr Obama said.