When Do You Change Ends in Tennis? Count Games, Then Points
Under the standard tennis rules, change ends after the first game and each later odd-numbered game of a set. During a standard tiebreak, change after every six points. Serving changes and end changes are separate sequences.

Add both players’ games
At a score of 2–1, three games have finished, so it is time to change ends. At 2–2, four have finished, so stay at the same end. Count completed games in the set, not only your own wins.
Check the set ending
At the end of a set, change ends unless its total number of games is even. After an even total, change after the first game of the next set. Do not add an extra change just because a new set starts.
Use points during the tiebreak
The standard tiebreak changes ends after every six points played in total. This does not mean six points for each player. Approved alternative formats can use a different pattern, so check the event rules before starting.
Keep the score when correcting a mistake
The ITF rules preserve points already played when players discover they are at the wrong ends. Correct the ends as soon as the error is found. Announcing the score before serving helps both players follow the next change.
Sources
ITF.