President Obama has apologised after two Western hostages were inadvertently killed in a US attack on an al Qaeda base in January.