If you make a mortgage with a bank, you will have to pay them, with out regard as to if your living in the house or not.
Many lenders have very sever lending requirements for those in your situation. Most will require a valid residency visa and usually a B 1 or 2, E 1 or 2, G 1 to 5, I, J1, K1, O1, and R1. You may Not be on an A type or F1, F2, or M1 type visa. Visa Termination date is also critical. You need to pre arrange your mortgage qualifications before you consider selecting property and have an exit plan/ disposal plan for the property to have it paid off by the time you leave or sale it. You will have to have a Tax Payer ID number if you sale as taxes will be withheld.
You need to talk with a qualified mortgage broker and if you can find one, a real estate agent familiar with dealing with foreign buyers. It is more complex than if you were a perminent resident but not one that is impossible if you have the correct visa.