You can read the entire file into a PHP string using the fopen() and fread() PHP functions like so:
$fp = fopen(get_template_directory_uri()."/header.php","r");
$header_contents = fread($fp,filesize(get_template_directory_uri()."/header.php"));
fclose($fp);
Then use the str_replace PHP function to find and alter your target word:
$modified_header = str_replace("what you are looking for","what you are looking for"."what you want to add after it",$header_contents);
Then save the modified contents back to the header.php file using the fopen() and fwrite() PHP functions:
$fp = fopen(get_template_directory_uri()."/header.php","w");
fwrite($fp,$modified_header);
fclose($fp);
You’ll need to make sure the user your web server or PHP runs under has write access to header.php, but be mindful that making it writable for this process means it is writable to ANY PHP script on your server and could potentially be exploited.