It is important to understand that the formatting of the text in the topic header box above the topic editor is handled differently in PDF and DOCX output. The formatting of the main text in the editor is exported to PDF and DOCX and used there. The formatting of the topic header is not exported – only the plain text is exported and the formatting is defined in the PDF or DOCX template.
This is necessary because in PDF and DOCX you can define different formatting for the headings on different levels. This formatting can only be defined in the template, since you don't have multi-level formatting definitions in your project.
You can't influence header formatting in PDF and DOCX from your project
What this means is that you can't influence the formatting of topic headers or TOC entries in PDF and DOCX from your project. All the header formatting in these two document types is defined in the PDF and DOCX templates, not in your project.