It's called tinnitus. There are a few different causes of it:
1. hearing loss: people who have significant hearing loss, are likely to have tinnitus. Not all do, but it's pretty common.
2. exposure to loud noises: go to a rock concert, leave it with your ears buzzing. Same with chainsaws and ball peen hammers. It is a side effect of damage to the ears.
3. Meniere's disease: an inner ear disorder
4. Regular aspirin use: some people experience this as a side effect of taking aspirin daily.
5. Random no particular reason: a few people just experience this once in awhile, for no discernable reason. Not very common, and not frequent. But you are likely to find people who say "hey that happened to me a couple of times, just showed up, went away, just like that, never did figure out why."
If you find it is happening more often, or during/after some specific activities that you notice, or is occurring with a pattern of frequency, you should have your hearing tested by an ENT doctor (not a hearing aid specialist, an actual doctor).
If it's just once in a blue moon and you can't find any sort of pattern to it, and it's not really bothering you but is more a "huh - how about that" moment, just pretend it's the aliens sending homing signals to your brain. It'll lighten your mood