I'm not sure if this is a better suggestion, but it was just an idea I had. You could purchase hair combs and attach the magnets to those. The combs would be removable and should hold within the wig hair, as long as the mask isn't too heavy. They would also hold the hair in place, preventing stray hairs from flopping over the top of the mask.

Or make a tube of thin fabric and put the magnets in the tube, before sewing around them (I'm assuming they're round magnets, but sewing in a square around them will be fine(maybe you can also glue but it might scratch at your head)), then sew the tube under the wig, if your magnets are strong enough.