You can sell your house and move out at anytime during the mortgage but it's best to wait a minimum of 7 years before you move out and sell your house with the current mortgage to allow you to buildup enough equity in the house.
Selling a house will require you to pay the full mortgage off to the bank so you''ll have to get enough money out of your current house to pay the mortgage in full.
If you wait 7 years or a bit longer the house may go up in value and you may make a good profit to put towards the other house.