You are assuming that you drop your payment amount when you payoff the $10k. If you assume that, then yes, you could pay less interest by applying the $5k to the larger loan, because it effectively keeps you paying the larger monthly payment (i.e., the combined amount of the payments on the $50k and $10k loan), so that's enough to offset the fact that you apply the $5k in a non-optimal way.
Paying the $5k to the $50k loan is the worst of both worlds. It doesn't free you of the payment on the $10k faster, and it doesn't save interest in an optimal way. The only thing that can be said for it is if you are concerned you are not disciplined enough to pay more on the $50k loan when the $10k loan is paid off, it forces you to pay a bigger amount for longer, effectively reducing your long term interest costs if you assume you will be undisciplined.
This is the concept I am trying to overcome looking at the math when talking to others. I honestly am not trying to create an argument, but honestly hash out the real answer. For even simpler comparison purposes (trying to prove the concept over specific situation) lets reduce it to 100k 5% 30 year mortgage (A) and 100k 7% 30 year mortgage with 2 years left (B) [thus current balance ~15k]. I have compared a handful of amortization tables and Payoff calculators for the math. The two scenarios are apply 5k at the beginning of (A) and adding the (B) payments in at year 28 OR applying 5k to (B) for a 10 month earlier payoff and adding those payments to (A) at year 28, 10 months. Monthly payment for (A) is $537 and (B) is $665.
The total principle payoff is the same. The only differences are the time until all loans are paid off and the total future combined interest payments.
If I pay 5k to (A) at the beginning of 30 years, the total interest paid is just under $30k. If I pay the 5k to (B), the total interest paid is over $39k. The payoff in both cases is basically 8 years (they are 1 month apart).
This is the math that tells me paying (A) is the smarter decision despite literally everyone stating pay (B). Both loans get paid off in 8 years with the difference being 9k in interest if you pay the mortgage near the end of it's life. And that is the reason I am asking this question.
Just to show you the math with your example. 2 loans:
Loan 1: 100k, 5% interest, 30 year term, $536.82
Loan 2: $14,859.54, 7% interest, 2 year term, pmt of $665.30 (this is the last two years of the 100k, 7% loan for 30 years).
Apply the $5k to Loan 1, effectively turning it into a $95k loan. Continuing to make the same 536.82, and after two years, your 7% loan will be paid off, allowing that $665.30 to be applied to Loan 1. Then you pay it off in another 7.64 years for a total of 9.64 years of payment, resulting in total interest payments on the $100k loan of $28,098, plus $1,107.66 for the $14,859.54 loan for a total of $29,205.66 in interest paid.
Conversely, if you apply the $5k to the $14,859.54 loan, you pay that off in 1.3 years, and payh $482.52 total interest. If you then apply the $665.30 to the $100k laon, you end up paying it off in another 8.32 years for a total of 9.6 years of payments, and pay a total of $29,084.75.
Basically tiny savings of $120.91 in interest. Which makes since because you were only going to carry that 7% loan for at most two years, and two years of 2% interest savings would be $200 (and obviously the final result would be less than that since you wouldn't be carrying that $5k balance for the two years, so it'd be just over half that savings because of the accelerated paydown of principle in the second year).