Hello,
Replacing WordFragment in headers feature was added in phpdocx 4.5, so it's not available in phpdocx 4.1, we recommend you to upgrade to the latest version available.
In your code, the whole paragraph is being replaced because you have added:
'type' => 'block'
this is block replacement. You need to use inline replacement or remove this line.
Regards.