This is very unlikely to cause any problems.
The magnets inside in-ear headphones are quite small and weak. They are designed to move tiny speaker drivers, not to generate a strong magnetic field. In contrast, hard drives like 2.5” HDDs store data on platters that require a much stronger and very focused magnetic force to be affected. The drive’s internal components are also shielded, so normal household magnets (like in headphones) simply don’t have enough strength to interfere with the data or damage the platters.
But if you’re still concerned, you can simply keep the headphones a bit further away from the HDD and check the drive’s condition to be safe. We have a guide that shows how to check hard drive health step by step (link to guide)