What determines whether you need to shock your pool or not?

Do you shock it only if something goes wrong (chemically), or is it like a maintenance routine that you do once a month or so??

Thanks in advance for any insight you can share with me.