Over-the-ear headphones can vary greatly, so the best option is usually to find the instruction manual that came with your model and read the cleaning instructions.
Modern headphones are designed with easy, convenient cleaning in mind, so there should be step-by-step instructions readily available that will avoid potential damage to your set.
Take extra care to clean the areas you touch the most, and consider doing a small test patch with rubbing alcohol if you are concerned about damaging the fabric.
A toothbrush will help you to get into any cracks or difficult areas and can be softer than a toothpick to avoid piercing any delicate areas.
You have to be especially careful about cleaning in-ear headphones and wireless earphones, as the fact that they go inside your ear means they can pick up more earwax and grime, and also increase the likelihood of an ear infection.
For in-ear headphones, don’t forget to also clean the case, which can also store grime, ear wax, and bacteria. A toothbrush and cotton bud are often the best tools for this job, as they can get into tough-to-reach places.
And if you often wear your earbuds during exercise or training where they might get sweaty, don’t forget to give them a quick wipe after you’re done, and give them a few minutes to dry outside their case before putting them back in, as warmth and moisture can help bacteria to grow.