The Philippines president has apologised to Germany for failing to stop the beheading of a German hostage by Abu Sayyaf militants in the south of the country.