I've certainly had this happen. While it didn't attach directly to the head, it attached to the steel roller bearings that moved the head, as well as the BL touch probe!
The type of magnet matters as well. If you're just using a regular steel or ceramic magnet, you probably won't have a problem since they usually aren't strong enough to lift themselves the inch or two required. But if you're using a neodymium magnet, then those certainly are.
I've done three things to solve it:
- Learned the tolerance of my machine so I know how large of an opening to make for the magnet so it ends up being a bit of a press fit (when designing my own stuff). It doesn't take much to offer just a little bit of resistance to prevent the magnet from lifting.
- When printing multiple items at once (made some refrigerator magnets), I arranged them so the print head travel properly and not cross over the magnets of the other items
- Used a glue stick to glue them in. I was a bit surprised this worked, but it was just sticky enough to solve the problem.
One of the best first prints I ever did was to create a cylinder, say 1" in diameter, with a hole in it (1/2" in diameter), then create the corresponding "pin" exactly 0.500". Then I'd create multiple cylinders with holes of varying tolerances, say 0.490, 0.495, 0.500, 0.505, 0.510.
Then I could compare the fit between the two items. Essentially if I needed to put a magnet into something, there's no way I can do a 0.500" hole. It's too tight. I've learned that with my printer, that if I oversize a hole by 0.01" diameter, then it's a nice fit with a little bit of resistance. Well worth taking a few minutes to do this.