Outcomes for hitting your ball with a practice swing on different areas of the golf course:

On the Tee: When you are playing a ball from the teeing area, the ball is not in play until a stroke is made at it. This means that when your ball is teed or on the ground in the teeing area and you make a practice swing that accidentally strikes and moves the ball, you have not made a stroke or moved a ball in play. The Rules allow you to simply re-tee that same ball or another ball without penalty. Note that there is also no penalty if this occurs when playing again from the teeing area after starting the hole (such as after hitting a ball out of bounds or hitting a tee shot that strikes a tree and ricochets back within the teeing area). This is covered under Rule 6.2b(5) and 6.2b(6). Please note that the “teeing area” does not include the entire tee box. It only includes the two club-length-deep area measured from the tees you are playing.

On the Putting Green: Just as in the teeing area, the Rules are lenient if this occurs on the putting green. If you strike and move your ball with a practice swing on the putting green (or accidentally cause your ball to move in any other way), you can simply replace your ball on its original spot without penalty and play on. This is covered under Rule 13.1d(1).

Anywhere Else: This category would include a ball that lies in a bunker, a penalty area, or anywhere in the general area (defined as anywhere on the golf course that is not the teeing area, the putting green, a bunker or a penalty area). When your ball lies in any of these areas, it is already in play. If you then take a practice swing and cause your ball to move, you still have not made a stroke, but you will get a one-stroke penalty for moving your ball in play. The ball must be replaced on its original spot. This is covered under Rule 9.4. If the player instead plays the ball from where it was moved to after their practice swing, it becomes a two-stroke penalty (or a loss-of-hole penalty in match play) and the player may or may not be required to correct their mistake (see Rule 14.7 for more information).

(Rules – Glo Malmberg)