Danish mortgage loans have several features that make them interesting: Short-term revolving adjustable-rate mortgages are available, as well as fixed-rate, 10-, 20- or 30-year annuities that contain embedded options (call and delivery options). The decisions faced by a mortgagor are therefore non-trivial, both in terms of deciding on an initial mortgage, and in terms of managing (rebalancing) it optimally.We propose a two-factor, arbitrage-free interest-rate model, calibrated to observable security prices, and implement on top of it a multi-stage, stochastic optimization program with the purpose of optimally composing and managing a typical mortgage loan. We model accurately both fixed and proportional transaction costs as well as tax effects. Risk attitudes are addressed through utility functions and through worst-case (min-max) optimization. The model is solved in up to 9 stages, having 19,683 scenarios. Numerical results, which were obtained using standard soft- and hardware, indicate that the primary determinant in choosing between adjustable-rate and fixed-rate loans is the short-long interest rate differential (i.e., term structure steepness), but volatility also matters. Refinancing activity is influenced by volatility and, of course, transaction costs.