I actually transferred while in graduate school, so I have some first hand experience on this. My research advisor took a new job and I wanted to continue my work with him so I followed him to the new institution.
There are a few things to consider when you transfer:
1. Will your credits transfer?
2. Is there a difference between the credits needed for graduation at the 2 schools?
3. Have you taken the qualifying exams yet (aka PhD candidacy exams)? If you passed will it transfer?
Some schools treat students with a previous masters and those coming straight from undergrad in the same pool, some schools do not.
All of these things should be weighed before you choose whether to transfer before or after you masters.