a few years ago I would have scoffed at this question, and said something like "if you hear a voice saying to 'obey my dog'" then you know.
BUT, recent work suggests that a strong magnetic field applied to the brain CAN CHANGE your personality or change decisions you would normally make. For now, you can just tell because someone is holding up a coil about the size of a shoebox to your head. But in the future...who knows?
Since so far it is ONLY MAGNETIC FIELDS that work this way...I would suggest some sort of hat with hall effect magnetic sensors in there, that sound an alarm if they detect a magnetic field of sufficient size to cause this effect.
It might be possible to fashion a hat using mu-metal that would counteract the external magnetic field