The Official "Play It As It Lies" Golf Rule
Improving the Situation
The Rules of Golf forbid improving the situation in which a golf ball has come to rest. This includes "moving, bending or breaking anything growing or fixed," moving or pressing down the surface on which the ball lies, making or removing "irregularities" on the playing surface, or moving any form of water (including dew or frost).
If your ball lands such that you are not able to stand on playable ground--such as if your stance would be on a cart path or sprinkler head--you may move your ball one club length from the spot where it lies, but not closer to the hole.
If you inadvertently move your ball while making your stroke or on your backswing, this is not considered improving your lie. The exception reads: "in making a stroke or the backward movement of (the) club for a stroke," as long as the stroke is made.
Exception: On the Tee
On the tee box--when beginning a hole--a player may improve the ground on which the ball is teed. For example, you may place the ball on a tee anywhere on the tee box and you may remove weeds, press down the grass around the tee or wipe away loose impediments. In addition, if the ball falls off the tee at or before address, you may re-tee without penalty.
Exception: On the Green
On the putting green, you may mark your ball and replace it at the spot where it landed. You may also repair the green in the line of your putt or remove any sand, dirt or other loose impediment.
If your ball lands in a hazard, and you touch the ground or water while trying to prevent a fall or while removing an obstruction, there is no penalty as long as you do not change the lie of the ball. In addition, after taking a stroke in a hazard, a player may "smooth the sand or soil in the hazard" even if the ball is still in the hazard, as long as the lie of the ball is not improved.