Our headboard fell off after getting home from our last trip last fall. I was making the bed and it just fell away from the wall. Pffft. It was only held on by a handful of tiny light gauge staples and was bound to fall off sooner or later. It has fabric stapled over 1/8" plywood with a little foam between.
I glued on a couple of 1/8" plywood strips on the back and used interlocking hidden mirror clips. Mounted 10 on the rear of the headboard and 10 on the wall. With some very careful measuring, the headboard slipped nicely onto the wall but took a few attempts with 2 of us. Wasn't trying to make the headboard removable and I used the clips because they were thin. Would not entertain the thought of stapling the headboard back on like it was. If it ever gets damaged or we want to change the fabric, it will be easy to remove.
Don't have a pic of the headboard back up but this is what it looks like.
We installed a thicker memory foam mattress 2 years ago and the headboard was too low and we couldn't push the mattress up against the wall. I mounted the headboard a few inches higher and now the mattress is where it should be and have a little more room between it at the wall opposite the headboard.