When can you clean a golf ball?

According to the Rules of Golf you are only allowed to clean the golf ball: 1) On the putting green 2) Between the play of two holes and 3) Whenever you are taking free relief or a penalty drop.

More about the rules of cleaning a golf ball

Cleaning it when you are not allowed to do so will result in a penalty, usually 1 stroke.

A golfer is not allowed to clean their ball in any other situation, including when the ball is in the fairway, when the ball is in the rough, when the ball is in a bunker, to see if it is cut or cracked (and therefore can be removed from play) or to identify it or to see if the ball is in a position where relief is allowed.