Once you enroll in Medicare, the IRS sets your contribution limit to your HSA to zero. What this means is, beginning the first month you’re enrolled in Medicare, you’re not allowed to contribute any monies into your HSA.
This limit also pertains to any period of retroactive Medicare coverage. If you continue to contribute, or your Medicare coverage becomes retroactive, you may have to pay a 6% excise tax on those excess contributions. If you happen to have excess contributions, you can withdraw some or all to avoid paying the excise tax.