Your loan agreement controls what you can do pre-divorce. Typically, if you are husband and wife at time of purchase and creation of the loan, the deed you have made both of you joint owners and the loan/mortgae is also in both names. To change ownership to only one of the owners requires a new deed under which the two spouses transfer ownership to just one such spouse. Loan agreements usually require that the loan be paid off in full if any transfer of the property is made, including any such transfer from the combined spouses to one.
If you go into a divorce proceeding, which decides who gets the property (which can be done by agreement), and the finances indicate the owner keeping the property can pay the loan, mortgage companies often allow the mortgage to continue on the same financial terms with the spouse keeping the property.