When is the right time to tell my advisor that I plan on leaving my PhD program?
It seems to me that @Mad Jack's comment, though perhaps practical, is unethical.  Funding in a PhD program is conditional on one's intention to complete the program. If you accept funding under the expectation that you will take a certain long term action, then if you clearly realize that you no longer have the intention to complete that action then you are behaving deceptively, hence unethically, by hiding that information.  In an academic job by contrast, you sign a yearly contract.  Unless/until you have tenure, you could be dismissed at the end of any academic year.  Even when you have tenure you are rarely receiving university resources which would be wasted if you did not have a multi-year commitment, and if you do find yourself in a position of receiving those resources with the intention of leaving, then you are behaving unethically.  

(Example: most universities which offer sabbaticals view them as investments for the future of the faculty member's academic career and their career at that university.  Many universities have a policy that one has to return to "active duty" for at least one year after a sabbatical.  Violating this policy would be unethical in a similar way, although it is also more explicitly against the rules.  A yet closer unethical faculty behavior would be to receive a multi-year grant to do X, to realize after the first year that you have no intention of continuing to do research on anything at all related to X but continuing to take salary from the grant in subsequent years.)

Moreover the suggested unethical behavior is in response to hypothetical undesirable behavior by someone else.  The OP does not know that behaving unethically is necessary in order to receive the outcome which is in her personal best interest.  In fact she does not definitely know that she wants to leave the program: rather, she has some good reasons to leave (lack of interest and enthusiasm for a future academic career) and other good reasons to stay for a while (a desire to get a degree).  The right thing to do is to talk to her advisor, be candid about her doubts, and get on a track that would allow her to gracefully complete a master's degree if she so chooses.  

Someone who cuts your funding for expressing doubts about the future is not behaving ethically.  In all programs that I'm familiar with, funding is guaranteed conditional on satisfactory progress, and having a frank conversation does not make satisfactory progress unsatisfactory.  If the OP's advisor behaves so badly as to cut her funding following that conversation, then the OP can seek recourse from the director of graduate studies or the department head and has an excellent case.  The fact that she's scheduled to teach in the fall strengthens the case: if the funding is cut and she leaves because of it, who teaches the class?   

The fact that not informing the advisor is setting him up for a crisis later on is also a significant consideration.  To accept mentorship and funding from someone while planning all the while to leave them in the lurch later is quite indefensible.  I'm not surprised that the OP is having feelings of guilt about it.  As she is learning, we know deep down at a visceral level when we are doing something that we think is wrong.  Doing the right thing has intrinsic rewards -- call it karma or neuropsychology, it's true nevertheless.  I think she will sleep far better at night knowing that she did the right thing and suffered financial hardship for no fault of her own than if she did what she knew was wrong for purely selfish reasons.  I know I would.  

Finally, having a master's degree from a program and advisor who will only say negative things about you when asked is far from ideal. Being able to play well with others is valued even more in "the real world" than in academia, so burning bridges in this way is not a smart move.