Millions of seniors get health coverage through Medicare. And while there are certainly aspects of the program that make it less affordable than it could be, the reality is that the cost of private health insurance would, for the typical retiree, likely exceed the cost of insurance under Medicare.

Medicare eligibility begins at 65. Your initial enrollment window kicks off three months before the month of your 65th birthday and ends three months after that month.

A person using a laptop on a couch with a dog looking on.

Image source: Getty Images.

But you don't necessarily have to sign up for Medicare during that window. And if you're someone who's in the habit of funding an HSA, then you may specifically want to hold off.

When you don't want to give up a host of tax benefits

HSAs aren't available to everyone. Rather, your health insurance plan must be HSA-compatible by meeting requirements for deductibles and out-of-pocket maximums. But if you are eligible to fund an HSA, you can enjoy a world of tax savings.

HSA contributions go in tax-free, thereby shielding some of your income from taxes. Funds that are invested get to grow tax-free, and withdrawals are tax-free as well, provided that money is used to cover qualified healthcare expenses.

But one thing you should know about HSAs is that you're not eligible to contribute to one if you're enrolled in Medicare. That holds true even if you only sign up for Medicare Part A, which some people do ahead of Part B since there's generally no premium cost involved.

As such, you may not want to rush to sign up for Medicare as soon as you turn 65 if you're still covered by a group health plan at that point. If you do, you'll have to stop making HSA contributions immediately.

You may be allowed to wait to sign up

You may have heard that failing to sign up for Medicare during your initial enrollment window can be a costly mistake. And there's definitely some truth to that.

For each 12-month period that you're entitled to Medicare but don't enroll, you risk facing a 10% surcharge on your Part B premiums for life. That could end up being very costly for you.

But that only holds true for people who aren't covered by a qualifying group health plan during their initial enrollment window. If you're on a qualifying group health plan (generally defined as one covering 20 or more participants), then you don't have to worry about signing up for Medicare on time. Rather, you'll get a special window to enroll that won't begin until you separate from your employer or lose your group health coverage.

For many people, it makes sense to sign up for Medicare as soon as they're able to. But if you're enjoying the tax benefits of an HSA, then you may want to wait if you have a good health plan through your job or through the job of a spouse. The more money you're able to put into your HSA, the easier it should be to cover your healthcare expenses once your career finally comes to an end.