Hello,
Please check the second example available on this page:
http://www.phpdocx.com/api-documentation/layout-and-general/insert-headers-Word-document-with-PHP
that shows a very similar code. You need to set the right scope of WordFragment classes.
Regards.