Pdf is one of the most unsuitable file formats to use as a starting point for converting it to docx. A pdf by itself is pretty much "dumb", it knows the position of letters etc, but not much more.
You want to take a step further up in your workflow to where your pdf came from. If you have the latex sources or if you can export your document into another file format like html, then you still have all the knowledge about the document structure.
You can then use pandoc to convert to docx. For example from latex to docx:
pandoc -s document.tex -o test.docx
which will result in an editable docx with headlines and everything: