You cannot open and continue making contributions to an HSA if you have enrolled in Medicare Part A or Part B, however, if you have established an HSA prior to such event, you can continue to make distributions. If you do enroll in Part A or Part B, you will lose eligibility to contribute in the first day in the month that you turn 65. Please note that oftentimes, when you enroll in Part A, the coverage is retroactive for 6 months, meaning that you would not be eligible to make HSA contributions for that 6 month period.
Source: IRS Notice 2004-2 Q&A 27
Updated: