The US military says a strike targeting Taliban in the northern city of Kunduz may have caused "collateral damage".
Offering his "deepest condolences", Mr Obama said he expected a "full accounting of the facts" and would then make a definitive judgement.
At least 12 MSF staff members and seven patients were killed in the incident.
The UN called the strikes "inexcusable and possibly even criminal", with Secretary General Ban Ki-moon calling for a thorough and impartial investigation.
"International and Afghan military planners have an obligation to respect and protect civilians at all times, and medical facilities and personnel are the object of a special protection," said UN High Commissioner for Human Rights Ra'ad Al Hussein Zeid.
The hospital, run by the medical charity MSF, was severely damaged by a series of strikes lasting more than an hour from 02:00 local time on Saturday. Dozens were also injured in the attack.
MSF president Meinie Nicolai described the incident as "abhorrent and a grave violation of international humanitarian law".
"All indications currently point to the bombing being carried out by international Coalition forces," MSF said.
A spokesman for US forces in Afghanistan, Col Brian Tribus, said on Saturday that US forces had conducted an air strike in Kunduz "against individuals threatening the force" at the same time.
He added: "The strike may have resulted in collateral damage to a nearby medical facility."
President Obama expressed his "deepest condolences" for the deaths in a White House statement.
He added: "The Department of Defense has launched a full investigation, and we will await the results of that inquiry before making a definitive judgment as to the circumstances of this tragedy."
MSF nurse Lajos Zoltan Jecs was sleeping at the facility when it was hit. "It was absolutely terrifying," he said.
He saw a fellow nurse "covered in blood, with wounds all over his body", a statement issued by MSF said.
Mr Jecs and other staff went outside when the bombing stopped.  "What we saw was the hospital destroyed. We tried to take a look into one of the burning buildings. There are no words for how terrible it was. In the intensive care unit six patients were burning in their beds."
The Afghan interior ministry said a group of 10 to 15 militants had been hiding in the hospital.
The Taliban denied that any of its fighters were there.
A Taliban statement described the air strikes which hit the hospital as "deliberate", and carried out by "the barbaric American forces".
There has been intense fighting in Kunduz since Taliban fighters swept into the northern city on Monday.
President Barack Obama says the US has launched a "full investigation" into air strikes that killed 19 people at an MSF-run Afghan hospital on Saturday.