How to ensure I will stay first author of my paper?
Journal editors don't want to become involved in fights about authorship.  However, it is a very well accepted ethical norm that a paper cannot be published without the consent of all of the authors and that authors can't be dropped from a paper after submission or author ordering changed without the consent of the authors.   It's good editorial practice to contact all of the authors of a paper and check for objections if any such change is proposed by the corresponding author.  

Thus you have the "nuclear option" of contacting the editor and telling him/her that this change in author order was counter to your prior agreement with the professor and that you no longer consent to publication. I'd recommend that you start by contacting the editor to find out whether the author order has been fixed by your professor.