Once you enroll in any part of Medicare, including Part A, you can no longer contribute to a health savings account. If you are considering collecting social security benefits, in general, you should stop making contributions six months before enrolling in Medicare to avoid a potential health savings account contribution penalty.