Unexpected medical expenses can really take a wrecking ball to your budget. Even people covered by  workplace health insurance these days will pay close to $1,500 before the plan starts paying.

So it’s important to know about all of the different ways you can save to pay for your out-of-pocket medical costs.

Something called a Flexible Spending Account (FSA) might be  a great savings tool for you, because it lets you put money away on a pre-tax basis, which can lower your tax bill while giving you access to funds to pay for many of your medical charges.

That money can go towards deductibles or co-pays for doctor’s visits, prescription medication, and many other medical needs.

Who’s eligible for an HSA and who’s not?

You can only get an FSA through an employer. So first things first, check with your health plan administrator or human resources department to see if your company offers one.

If you’re self-employed or enrolled in a Marketplace plan, you aren’t eligible to open an FSA. You may, however,  be eligible for an Health Savings account (HSA), which is a similar type of account.

What kind of expenses are FSA-eligible?

The IRS’s list of permitted expenses is extensive, including things such as eye surgery, hearing aids, and dental work. Diagnostic tests like blood sugar test kits and pregnancy tests are also covered.

How much can I put aside?

If your employer offers an FSA, you can contribute up to $2,600 annually.

Your employer can also match your contributions up to an additional $2,600 each year–meaning you can put up to $5,200 away, if your employer contributes the maximum.

Your contributions to an FSA are deducted from payroll on a pre-tax basis, which means you don’t have to pay income taxes on the money you set aside. You can use the funds throughout the year to pay for qualified out-of-pocket medical expenses. Since you’re paying with pre-tax dollars, it’s like getting a 30% discount on your medical costs for the average account holder. You can find out more about what qualifies here.

If your employer offers an FSA, you can contribute up to $2,600 annually.

Is an FSA for everyone?

If you have recurring or predictable medical expenses, like prescription medications or managing a chronic condition, enrolling in an FSA might be a wise idea. You already know you’ll need the funds you set aside, so you may as well take advantage of the tax break. The same goes if you’re anticipating a costly surgery or medical procedure during the benefit year.

On the other hand, if you rarely incur out-of-pocket medical expenses, an FSA might not be for you.

What happens if I don’t spend all the money in my FSA before the end of the year?

This is really important: You should avoid contributing more than you know you’ll  spend in the course of a year, since an FSA is primarily a use-it-or-lose-it account. That means you don’t get to keep any unused money you’ve put away for the year. Any unused amount goes straight to your employer, who can use the cash to pay for the plan’s administrative costs.

Some employers, however, may offer plans with a roll-over option. In that case, up to $500 can carry from the previous year into the following year’s FSA.  That will not affect your contributions for that year.

Alternatively, some employers offer an option for a two-and-a-half month grace period to use the money in your FSA at the start of the following year. But employers aren’t required to offer either of these options, so you should check with your plan administrator to make sure the money you set aside doesn’t go to waste.

What are the rules and restrictions on an FSA?

You can’t use FSA funds to pay for health insurance premiums that you already claim as a tax deduction, as would be the case with most employer-sponsored plans. Also, certain services including cosmetic surgery and gym memberships are ineligible. Controlled substances such as marijuana aren’t covered either—even if it’s legal for medicinal use in your state, FSA funds won’t cover any substances that aren’t legal under federal statutes.

The IRS also specifies that items “ordinarily used for personal, living, or family purposes”—like a toothbrush and toothpaste—can’t be covered through your FSA. Check with the IRS to confirm whether an expense is eligible.

Can I spend my FSA money on over-the-counter medications at the end of the year to burn through my remaining balance?

You can only use FSA funds to pay for  over-the-counter medications when they’ve been prescribed by a doctor. The one exception to this rule is insulin, which can be reimbursed without a prescription. If you spend FSA money on unqualified expenses, the IRS will hit you with a 20% penalty on top of being required to pay tax on the amount withdrawn.