Pay careful attention to signs and pavement markings. Since it’s illegal to change lanes over a solid white line, make sure the line is dotted before you move.
I’m not sure there’s a cut-and-dry answer for this. Do it sometime when it is safe, not crossing solid white lines, and not too far in advance that you are blatantly driving in the bus lane for miles and miles and receive a ticket. Usually I would aim for about 3/4 – 1/2 block. If you wait too long and get too close to the intersection, other vehicles may be in the space, so consider the vehicle behind you and remember to signal early.
After the last lane-way, might be a good rough guideline:
Perhaps, “After the last parked car,” can be a guideline.
If anyone has a better answer, let me know.