Helmets, whether they be bicycle or motorcycle helmets, are designed to only protect against a single fall. If your is ever hit during an accident, you should definitely replace your helmet even if it looks fine.
This is also why you should never buy a used helmet as it can be very risky.
Helmets also expire after a few years and manufacturers even recommend to replace them after 3 years. You should thus be replacing your helmet at least once every 5 years.