A hairnet will certainly do the trick. Some helmets come with an "insect liner" that replaces the normal internal pads with a big part-net-part-padding apparatus kinda shaped like a stingray. My wife's Kali Phenom came with one. Have never used it.
I have had too many bees to count go into my helmet (they still grow oranges around here) and about half of those guys manage to get the stinger into my head, which is super fun-- 2015 led the charts with half a dozen stings (including one on my thigh.) So earlier this year I purchased myself a Smith Overtake, and will never have a bee sting me on top of the head again... at least while on a bicycle.
So at the opposite ends of the spending spectrum, hairnets or an Overtake. I went the helmet route, because I'm not gonna stretch a hairnet over my helmet every time I leave the driveway.
__________________