According to the PHP doc, SimpleXMLElement::xpath() returns an array. You can't chain it with insertComment().
EDIT : You can use isertComment with SimpleDom but only on the value :
$result = $xml->xpath("//string[@name='debug']")
$result[0]->insertComment(' This is a test comment ', 'after'); // after, append or before
$xml->asXML('test.xml');