It's a playful way of saying someone is being annoying or intrusive. It can be used in a variety of situations, from a friend wanting to chat when you're busy to a coworker asking for help with a task you don't have time for.
The phrase originated from the literal act of removing something from one's hair, like a pesky fly or a stray strand. Over time, it transitioned to represent the act of removing an unwanted presence or interruption.