It's not a secret that healthcare is a major expense for both workers and retirees alike. But during your senior years, the cost of medical care could skyrocket.

HealthView Services projects that the average healthy 65-year-old couple who retired last year can expect to spend a whopping $662,156 on healthcare costs throughout retirement. That number accounts for out-of-pocket Medicare expenses and projected healthcare inflation of 5.9% a year.

It's for this reason that it's so important to set money aside specifically for healthcare in retirement. And one account is becoming more popular in that regard.

A smiling person at a laptop.

Image source: Getty Images.

HSA balances are growing

As of January, consumers had saved more than $100 billion in health savings accounts (HSAs), according to consulting firm Devenir. And the firm also projects that HSA funds will reach $150 billion by the end of 2024.

All told, an estimated 32 million consumers have an HSA. That's a pretty impressive number, given that HSAs aren't open to everyone.

In fact, eligibility to fund an HSA hinges on being enrolled in a high-deductible health-insurance plan. Some consumers prefer a plan with a lower deductible or aren't offered a high-deductible option by their employers. Medicare enrollees also aren't eligible to participate in an HSA. So the fact that so many millions of Americans have one is a good thing.

Still, there are no doubt plenty of people with HSA eligibility who have yet to fund one of these accounts. And that's a big mistake, seeing as how HSAs are loaded with tax benefits.

The upside of HSAs

HSAs offer a host of tax breaks that make maxing one out worthwhile. First of all, HSAs are funded with pre-tax dollars. Traditional IRAs and 401(k) plans enjoy similar treatment.

Furthermore, HSA funds that aren't needed right away can be invested. HSA investment gains are tax-free. Withdrawals are tax-free, as well, provided the money is used for qualified healthcare expenses.

It's also worth noting that HSAs effectively convert to a traditional retirement savings plan once savers turn 65. Withdrawals taken at a younger age for non-medical purposes are penalized to the tune of 20%, which is double the penalty for taking an early withdrawal from an IRA or 401(k).

But come age 65, HSA savers can access their money for any expense and avoid penalties. In that scenario, taxes do apply to withdrawals, but that's no different than the taxes that come into the mix with traditional IRAs and 401(k)s.

Don't pass up a solid savings opportunity

If you have a chance to fund an HSA, it pays to do so. But if you're going to go that route, aim to invest your HSA and reserve that money for retirement, when you're likely to need it the most.

Devenir's research reveals that only 7% of all HSAs have funds invested. That suggests that most savers are using their HSAs to cover near-term expenses. While that's most certainly allowed, it's also not the best way to make the most of an HSA.