To avoid a tax penalty, you and your employer should stop contributing to your Health Savings Account (HSA) 6 months before you retire or apply for benefits from Social Security (or the Railroad Retirement Board).
If you’re 65 or older, your Part A coverage will start up to 6 months back from the date you sign up for Medicare or apply for benefits from Social Security or the Railroad Retirement Board. You’re not eligible to make contributions to your HSA after you have Medicare. If your Medicare Part A coverage overlaps when you or your employer made contributions, you’ll have to pay a tax penalty.
You can withdraw money from your Health Savings Account after you sign up for Medicare to help pay your share of costs (like deductibles, premiums, coinsurance or copayments).
For more info Click Here