I think the math is a little more complicated than that. The expected return on the 401K and the benefit of delaying (or, as noted above, removing altogether if a FIRE candidate who can do the Roth shuffle) the taxes due on those earnings need to be compared to cost of the debt. It's not a comparison of 25%, which is a marginal tax rate, to the 7%.

One (among many) ways to look at it - assume:

1) The loan will be paid off in 5 years. $115K at 7.55% over 5 years = $2,307.10/mo, so assume that after-tax cash flow is available.

2) A $36K lump sum is available, and can either go into 401k funds or (after paying tax) pre-paying loan principal.

3) Income is too high to use the SL interest deduction on federal taxes

4) Investments earn 5%

5) Marginal tax bracket is 28%

If the $36K goes into the 401k, after 60 months

- the mortgage is paid

- the 401k funds have grown to $45,946.14

If the $36K goes toward the loan principal,

- $10,080 is paid in taxes, and $25,920 pays principal

- the loan is paid after 45 months, with a final month payment of $1,074.51, leaving $1,232.59 for investment that month

- for the remaining 15 months, the $2,307.10 is invested in a taxable account

After 60 months,

- the mortgage is paid

- the taxable account has grown to $36,946.23 with a basis of $35,839.09

Then the question becomes, "which is worth more: $45,946 in a 401k or $36,946 in taxable?" That answer isn't straightforward, because it depends not only on the tax rates but the number of years before the money is withdrawn. E.g., if

P1, t1 = the 401k principal and tax rate

P2, t2 = the taxable principal and tax rate

we have for after tax values:

401k = P1 * (1+i)^n * (1-t1)

taxable = P2 * (1+i)^n * (1-t2) + t2*P2 (because the tax is due not on the entire amount but only the amount above the basis)

Of course, if t2=0 then the ratio 401k/taxable reduces to P1/P2 * (1-t1).

With P1 = 45,946 and P2=36,946 the options are equal (with t2=0) when t1 = 19.6%.

So - assuming all the above assumptions hold - if the expected overall tax rate on the 401k withdrawals in retirement is <19.6%, put the money in the 401k. Otherwise prepay the loan.

If, however, the capital gains tax on the taxable withdrawals is 15% instead of zero, the breakeven (i.e., above which the loan prepayment is better) 401k withdrawal taxes become

for 10 years, 24.2%

for 20 years, 27.1%

for 30 years, 28.9%

If reality differs from the assumptions, the conclusion may also change. E.g., if the investment returns are 8% instead of 5% the breakeven 401k withdrawal tax rates are

For t2=0, 28.9%

For t2=15%,

for 10 years, 34.6%

for 20 years, 37.2%

for 30 years, 38.5%

If the current marginal rate is higher than 28%, that will increase all the breakeven rates calculated above (i.e., make it more likely the 401k is the better option).

ETA one other assumption: no taxes on the taxable account until withdrawn (e.g., all increases due to capital gains alone). Imposing any annual taxes makes the 401k that much better.