When or how often should I replace my bike helmet? I’ve fallen a couple times, but no serious damage is visible on the helmet except for a couple divots here and there.

Should I consistently be replacing my helmet after a certain amount of time?  After every relatively serious fall?
Helmets should be replaced roughly every 5 years and after any crash where your head makes contact with the ground.

Helmets will crumble, compress or otherwise deform in sometimes hard to see ways when you hit the deck. The structural integrity of the thing will be massively diminished after even a relatively tame fall. This is one area where you don't want to mess around much.