He did not only teach at school, he also wrote novels.
In this sentence, should we use "didn't" instead of "did not"? Is it natural or common? Thanks a lot.
I would rearrange to sound better:
Not only did he teach at school, he also wrote novels.
Unless the context in which this sentence is written is informal, no, you should not use contractions.
The rule of thumb is that contractions are reserved for speech and informal writing or characteristic dialogue.
As mentioned by other users, you should also consider rewording the sentence:
Not only did he teach at school, but he also wrote novels.