Helmets that have not been used in a crash typically last up to 3 seasons, however varying degrees of use can change their lifespan. It is best to store the helmet in the provided helmet cover/case in a cool, dry, and untouched state (aka not under heavy objects, squished in the attic between skis, etc). At the beginning of the season and periodically throughout the season, it is best to evaluate your helmet. Look for any damage on the inside and outside of the helmet, such as cracks, deep scratches, dents, faded color on the exterior of the helmet, broken foam on the inside of the helmet, etc. If there is any sign of breakdown in the helmet, it is best practice to replace it. If the helmet seems to be intact and has not been in a crash, your helmet can be worn on the slopes.
Helmets should always be replaced after a crash in which it was used. Even if the helmet does not seem to be damaged on the outside, the helmet could be internally damaged (unfortunately there is no way to determine if there is internal damage short of cutting the helmet in half).