There are certain expenses in retirement everyone knows to plan for. You have to make sure you can pay for housing, transportation, food, and other basic necessities. You're probably also aware that you might do your fair share of medical spending once you retire, since health issues tend to arise with age.

But you may not realize how financially catastrophic a bigger health issue could be when you're retired and living on a fixed income. In a recent survey by Edward Jones, 45% of respondents said a health issue upended their retirements. If you want to avoid a similar situation, make sure to set aside funds for healthcare spending so you're not forced to scramble.

A person at a table with a laptop and documents.

Image source: Getty Images.

Fund an HSA if you can

It's more than possible to put extra money into an IRA or 401(k) plan so you have funds to tap for future healthcare costs. But an even better bet may be to contribute money to a health savings account, or HSA, if you're eligible to do so. To fund an HSA, you must have a compatible high-deductible health insurance plan.

The reason it pays to contribute to an HSA is that you'll have specific funds earmarked for medical bills. If you comingle all of your funds in an IRA or 401(k), you may not be disciplined enough to reserve money specifically for healthcare costs.

It's also worth noting that HSAs offer more of a tax break than IRAs or 401(k)s individually. With a traditional IRA or 401(k), contributions are tax-free, but investment gains and withdrawals are taxed eventually.

With a Roth IRA or 401(k), there's no tax break on contributions. Investment gains and withdrawals aren't subject to taxes, which is nice.

HSAs, however, give you three distinct tax breaks. Your contributions are tax-free, investment gains aren't taxed, and withdrawals aren't taxed as long as you use your money for qualified medical expenses. These can run the gamut from copays to coinsurance to services not covered under Medicare.

Don't let a medical issue wreck your senior years

Coping with a medical episode is difficult enough in its own right from a physical and emotional standpoint. You don't need the burden of medical debt to make things worse.

That's why it's so important to have funds at the ready for healthcare bills in retirement. And if you're able to save in an HSA, it's really worth doing so.

Remember, too, that HSA eligibility on your part can change as your health plan changes. Even if you weren't able to participate in an HSA in the past, it may be possible to contribute funds to one of these accounts now.

You don't necessarily need your employer to make an HSA available to you. As long as your health plan is HSA-compatible, you can open an HSA independently and set money aside so that if medical bills arise later in life, they don't have to put a major damper on your retirement.