The headers are in theory optional. I guess if one only sticks to the repo not needed. Me personally i always install them explicit. If you have them on the current kernel and install a new one they are pulled automatically for the new kernel too. At least with mhwd, no idea if pacman does it.
I guess they have to be hard dependency for dkms, but i am on the phone and cannot check.
The best approach would be to check if installed. pull the kernel version with uname, clean the output with awk sed grep whatever and put it in variable and theck if linux$(ver)-headers is installed.