How to deal with baseboard heating causing problems with a headboard?
Attach some spacer blocks to the backside of the headboard or the wall  that match the thickness or distance from the headboard  to the wall.  You could use raw wood or wood covered with a matching fabric,  you could build a nook or shelf space to fill that space for storage.  You could reinforce the headboard to the bed frame  with beefy hardware and or gusset braces  so that it will withstand the flexing.