[For a primer on HSAs, start here: Health Savings Accounts, 220,000 Reasons Why You Need One.]
If you are working past age 65 and covered by an employer-sponsored health plan that is HSA compatible (a high deductible health plan or HDHP), you could in theory continue to fund a Health Savings Account with employee or employer contributions. However, an HSA contribution is only allowable if you do not have any other type of insurance. So, if you sign up for Medicare Part A (or any other Part), you would be disallowed from continuing to make new HSA contributions. Many health plans require coordination with Medicare at age 65, so be sure to check with your insurer.
If you choose to not sign up for Medicare at age 65, it is very important to maintain records that you were covered by an employer sponsored health plan. Otherwise you will pay permanently higher premiums for Part B when you do eventually enroll.
Luckily, if you have an existing HSA, there are lots of uses for your account. Just like before you started Medicare, you can use funds in an HSA to pay your out-of-pocket expenses like your doctor or hospital co-pays and prescription drug costs. You can use your HSA to pay for dental, vision, or other medical expenses not covered by Medicare.
Additionally, Medicare participants can use an HSA to pay for their premiums for Part B, Part D, or for a private Medicare Advantage plan. If your Medicare premiums are deducted from your Social Security check, just reimburse yourself from your HSA and keep detailed records as proof. Retirees may also use their HSA to pay a portion of their premiums towards a Long-Term Care policy, if they have one.
You can use an HSA to reimburse yourself for medical bills for past years, again providing you can document and prove these were qualified expenses. When you pass away, if you have listed your spouse as beneficiary, your spouse can inherit your HSA, and treat it as their own. Then they can also access the money tax-free for qualified medical expenses. However, if your HSA beneficiary is not a spouse (or one is not named), then the account will be distributed and that distribution will be taxable.
For Medicare participants interested in an HSA-like option, there is the Medicare MSA. This is a Medicare Advantage Plan which provides a cash account for expenses, but not fewer tax benefits than an HSA. Details from Medicare here.