If the smell only happens when you run hot water, your water heater might have a buildup of bacteria. This is more common if you have well water or haven’t used the heater in a while.
The simple fix is to turn up the temperature to 140°F (60°C) for a few hours. This kills the bacteria. Don’t forget to turn it back down to a safe 120°F (49°C) afterward, or you risk scalding yourself.
If the smell persists, you might need to replace the anode rod inside the tank. It’s a job for a plumber, but it’s a one-time deal that ends the smell forever.