First, to avoid this:
Each time you do something you haven't done before or could involve frequency, reduce your audio device's volume and check if anything goes wrong.
or
Put a limiter/compressor on your master output while creating, so certain frequencies aren't intolerable. (More convenient.)
Give your ears a break every 20-30 minutes when making music.
Because I live in a city, silence is nowhere.
THese are basic tips, someone else could probably give you better tips.