A relatively simple way to do this without VBA:
Select the body of the document (Ctrl+A).
On the Review tab of the ribbon, click Restrict Editing.
Tick the check box "Allow only this type of editing in the document".
Leave the dropdown set to the default "No changes (read only)".
Under Exceptions, tick the check box for Everyone.
Click "Yes, Start Enforcing Protection".
If you wish, enter a password (don't forget it - you'll need it if you ever want to unlock the document), then click OK.
Save, close and reopen the document. The header and footer won't be editable.