You could purchase now, and stay within a price range that will ensure that you can capture the full PITI (principal, interest, taxes and insurance) after 5 years, by turning that home into an investment property & renting the home out. If you secure a renter with a lease, you can use that to help qualify for a new mortgage in your new city. Of course down pymt, fico score,debt to income ratio will all be analyzed again.
You could sell your home before you move, hopefully with enough equity for a down payment on your next home. Very hard to say where rates will be in 5 years, but inflation is ahead, we keep hearing, that will drive rates up evntually.
As others have already stated correctly, the loan is attached to the property and will not transfer. If you find a super deal now, you may just be in a good position in 5 years. Good Luck, let me know if you want any help!
Windermere Real Estate SoCAL