When do I tell my advisor that I'm leaving the PhD?
I've had experience with similar issues and in my opinion, honesty is the best policy assuming that your advisor is a reasonable, non-vindictive person. If the issue is just the topic and the area, and not your advisor personally, then they probably want what's best for you and could actually help you out in working out the details (perhaps offering you an interim position so that you don't lose everything, or agreeing on you acting as a visiting scholar in your institution while your admission to the other place is finalized etc.). If your advisor is not on your side, then I would get out regardless, even risking going back to your home country. There's no point in suffering through a PhD you hate.