HpHDHPvsPPO.com
Updated May 2026

HSA and Medicare Rules: The Traps That Catch People Every Year

The HSA and Medicare interaction is the single most common source of tax surprises in late-career HSA savers. Enrolling in any part of Medicare ends your ability to contribute to an HSA. Enrolling in Social Security at or after 65 automatically enrolls you in Medicare Part A retroactively for up to 6 months. The retroactive enrollment can claw back HSA contributions you thought were legitimate, creating excess contributions subject to a 6 percent excise tax. We see this trap snag dozens of households per year.

This page covers the six most common timing traps, the rules around what Medicare-related expenses the HSA can pay (Parts B, D, MA yes, Medigap no), and the practical sequencing for a clean transition from HSA-eligible employment to Medicare-and-HSA-spending retirement.

The six timing traps to avoid

TrapConsequenceHow to avoid
Enrolling in SS at 65 while contributing to HSARetroactive Part A enrollment claws back up to 6 months of HSA contributions as excess (6% excise tax/year)Stop HSA contributions 6 months before SS enrollment
Auto-enrollment at 65 if already on SSMedicare A and B effective first of birthday month, HSA contributions stop that monthPlan SS timing carefully if want to continue HSA
Spouse enrolls in Medicare, you still on family HDHPIf spouse's Medicare disqualifies their HSA but not yours, family contribution split must reflect spouse's ineligible monthsRecalculate contribution limits with pro-rated math
Mid-year Medicare enrollmentHSA contributions for the year are pro-rated to HSA-eligible months onlyProrate your contribution and stop payroll HSA deductions
Last-month rule misuseContributing the full annual limit based on December eligibility, then losing HDHP coverage in Q1 of following year triggers full year tax-backMaintain HDHP for full following year if using last-month rule
Paying Medigap premium from HSANon-qualified distribution, taxable plus penalty if under 65 (no penalty after 65 but still taxable)Pay Medigap from non-HSA source, HSA only for B/D/MA premiums

The core rule and where it comes from

Under IRC Section 223(c)(1)(B)(iii), enrollment in any part of Medicare (Parts A, B, C/Medicare Advantage, or D) makes you ineligible to contribute to an HSA. The ineligibility begins the first day of the month you become enrolled. IRS Publication 969 spells this out, but the SSA and Medicare enrollment processes do not coordinate with HSA contribution paperwork, leaving the taxpayer to manage the interaction.

Critical nuance: enrollment in Medicare Part A is automatic when you start Social Security at 65 or older, and this auto-enrollment is retroactive for up to 6 months (or back to your 65th birthday if more recent). This is the most common trap. A 65-year-old who is still working, still on an HDHP, and still contributing to an HSA, then files for Social Security in October, can have their Medicare Part A retroactively effective back to April. Six months of HSA contributions become excess contributions, taxable plus 6 percent annual excise tax until withdrawn.

The exception: if you have continuously been HSA-ineligible due to other Medicare enrollment (e.g., you had Medicare from before age 65 due to disability), the retroactive 6-month rule does not extend back further than the date of original Medicare entitlement.

The continuing-to-work past 65 playbook

Many late-career workers want to continue working past 65, stay on their employer's HDHP, and continue contributing to their HSA. This is possible but requires careful sequencing.

Step 1: Do not enrol in Social Security at 65. Delay until you have officially stopped HSA contributions. Social Security can be delayed up to age 70 with delayed retirement credits adding roughly 8 percent per year to the benefit amount.

Step 2: Do not enrol in Medicare Part A at 65. If you are not on Social Security, you can decline Medicare Part A. If your employer has 20 or more employees, you are not required to enrol in Medicare while covered by the employer group health plan, the employer plan remains primary.

Step 3: Stop HSA contributions 6 months before you plan to enrol in Social Security. This buffer protects against the retroactive Part A enrollment. If you plan to retire and start Social Security at age 67, stop HSA contributions at age 66 and 6 months. The buffer time is unproductive (no HSA contributions for 6 months), but the alternative is excess contribution penalties.

Step 4: At the planned retirement date, enrol in Medicare Parts A and B during your Special Enrollment Period (you have 8 months from the end of employer coverage to enrol without penalty). Then enrol in Social Security. The order matters less than the timing.

What the HSA can pay for after Medicare enrollment

After Medicare enrollment, you can no longer contribute to the HSA, but you can spend the existing balance on qualified medical expenses tax-free. Per IRS Publication 502 and 969, this includes:

NOT eligible: Medicare Supplement (Medigap) premiums. This is the most common mistake. Medigap is explicitly excluded by IRS Pub 502. If you have Medigap coverage (Plan G, Plan N, etc.), pay those premiums from non-HSA sources.

The pro-rata calculation for mid-year Medicare enrollment

If you enrol in Medicare mid-year, your HSA contribution limit for that year is pro-rated based on the number of months you were HSA-eligible. The formula: annual contribution limit x (eligible months / 12). For 2026, a 65-year-old with self-only HDHP coverage who enrolls in Medicare effective July 1: 6 months eligible / 12 = 0.5 multiplier x $4,400 limit = $2,200 maximum contribution for the year.

The catch-up contribution ($1,000 for age 55+) is also pro-rated by the same formula. So the 65-year-old above can contribute $2,200 regular + $500 catch-up = $2,700 maximum.

The last-month rule provides an alternative: if you are HSA-eligible on December 1 of the year, you can contribute the full annual limit for the year (not pro-rated), but you must remain HSA-eligible for the entire following 13-month testing period. If you fail the testing period (e.g., enrol in Medicare in Q2 of the following year), the full-year contribution is treated as if it had been pro-rated, and the excess becomes taxable plus a 10 percent additional tax penalty.

For someone planning to enrol in Medicare in mid-year of the following year, the last-month rule is risky. Stick with the simple pro-rata calculation for that year, and avoid the testing period exposure.

Frequently asked questions

Does enrolling in Medicare stop my HSA?

Enrolling in any part of Medicare stops your ability to contribute to an HSA, starting the month enrollment begins. You can still spend the existing HSA balance on qualified medical expenses tax-free, including Medicare premiums for Parts B, D, and Medicare Advantage. The HSA does not disappear, it just stops accepting new contributions.

What is the Medicare Part A retroactive enrollment trap?

When you enroll in Social Security at age 65 or later, you are automatically enrolled in Medicare Part A retroactively for up to 6 months prior to your enrollment date. If you have been contributing to an HSA during those 6 months, those contributions become excess contributions subject to a 6 percent excise tax until corrected. The fix is to not enroll in Social Security until you have officially stopped HSA contributions and waited the buffer period.

Can I use my HSA to pay Medicare premiums?

Yes for Parts B, D, and Medicare Advantage premiums. These are qualified medical expenses payable tax-free from an HSA at any age. No for Medicare Supplement (Medigap) premiums, which are explicitly excluded by IRS Publication 502. This is a meaningful exception, many retirees mistakenly try to pay Medigap premiums from their HSA and create non-qualified distributions.

When can I start contributing to my HSA again after leaving Medicare?

If you disenroll from Medicare (rare but possible) and return to HDHP coverage with no other disqualifying coverage, you can resume HSA contributions the month after disenrollment is effective. This typically only applies to people who took Medicare while still working, then opted to drop it to stay on employer HDHP. The mechanics are complex, work with a Medicare-credentialed advisor.

What happens to my HSA when I die after enrolling in Medicare?

Same beneficiary rules as before Medicare. Spouse named as beneficiary: HSA becomes spouse's HSA tax-free. Non-spouse beneficiary: entire balance is ordinary income to beneficiary in year of death. Always name your spouse as primary beneficiary if married. Medicare enrollment does not affect the inheritance treatment, only the contribution eligibility during your lifetime.

Related topics

Not tax, legal, or financial advice. Based on IRS Publication 969, IRS Publication 502, IRC Section 223, and CMS Medicare enrollment rules. The HSA-Medicare interaction is highly fact-specific, particularly for households with one spouse continuing to work past 65 and another already on Medicare. Consult a Medicare-credentialed advisor and CPA before making enrollment decisions.