When their monthly health-insurance premium doubled from $600 to $1,200, Jay and Marya Margolis of Radnor considered their options to lessen the blow.

Perhaps Jay, who's 66 and a dependent on the plan offered by Marya's employer, could switch to Medicare — the publicly funded health program would have a lower premium. Jay requires an injected medication that costs thousands a year, though, and his drug costs under Medicare could be higher.

"The question became, with what I need, do I stay on my wife's insurance? Or do I go to Medicare?" he said.

It's a question that's coming up with growing frequency, as more people work past the traditional retirement age, into their late 60s and 70s.

Almost everyone is eligible for Medicare at age 65, and if you're already receiving Social Security benefits, you'll be automatically enrolled. But people who haven't begun receiving Social Security benefits will need to sign up when the time comes, and if you miss your initial enrollment period or don't qualify for a special enrollment period later, you could wind up paying penalties for the duration of your coverage under the program.

But many people who keep working are allowed under Medicare rules to keep their employer-sponsored health plan without penalty until they retire — and they may find this is a cheaper alternative to enrolling in Medicare right away.

Deciding whether that's the most cost-effective option will involve a lot of number-crunching.

It's confusing even for Jay Margolis, who spent his career as a pharmaceutical data analyst, knee-deep in insurance jargon.

"It's not like I'm going in there naive, but even for somebody like me, because of all the different companies that are out there and they each have different ways they model their plans, it really is very difficult for the layperson. You'd have to put a lot of time into studying," he said.

The process may seem daunting, and exposing your age by asking your employer for clarification may be uncomfortable. But ignore at your own peril, enrollment experts warn. People who are required to sign up for Medicare have a seven-month window surrounding their birth dates. If they don't, they will pay a penalty for the duration of their coverage under Medicare. The amount of the penalties vary because they are based on the length of time a person went without coverage.

"The cost of missing the window is quite high, if you don't realize your employer requires you to have Medicare coverage and you don't enroll," said Lina Walker, vice president of health security at AARP Public Policy Institute.

Baby boomers in their 60s and 70s are the fastest-growing demographic in the workforce. Employment among people age 65 to 74 is expected to rise 55 percent between 2014 and 2024, far outpacing the overall workforce growth rate, according to the U.S. Bureau of Labor Statistics.

The trend is fueled by a number of factors: People are healthier, which means they're physically able to continue working and expect to live longer, meaning they will need extra savings. After the last decade's recession struck at their peak earning potential, many find they can't yet afford to retire.

The age at which people can collect their full Social Security benefits has been creeping up — it's now 66 — and many people choose to continue working until then.

"Most of the people I'm meeting are working past 65," said James Long, a broker-manager with Young's Insurance Services  Inc. in Fairview Village, Montgomery County. "It's the majority now."

And the first question they ask, Long said, is when to transition to Medicare.

The first step is to figure out whether your employer requires you to enroll in Medicare when you turn 65.

People who have health insurance through an employer with at least 20 employees and who are actively employed by the company can keep their private insurance without penalty.

Those working for small companies with fewer than 20 employees need to transition to Medicare when they become eligible at 65.

If you have the option of holding onto health insurance through work, deciding whether you should will require comparing the total cost of your current plan — not just the premium — to your Medicare options.

Some details to consider, in addition to the premium, are the plan's deductible, coinsurance and copays; how the plan covers the medications you take; and whether you can continue seeing your doctors.

Employer-sponsored plans pay about 80 percent of the cost of health insurance for employees, but they often require employees to pay a greater share of the cost of covering dependents. So if you are over 65 and covered by a spouse's employer-sponsored plan, it's worth finding out how that plan pays for dependents.

"The whole Medicare puzzle is kind of difficult to untangle when you're first starting out," said Judith Cooper, of Philadelphia, who is in her 70s. "I feel like I'm in a maze."

Cooper retired at the end of October from her job as executive director of Play and Learn, an early-childhood education organization in Montgomery County that she helped establish in the 1980s.

Cooper held onto the organization's health plan after turning 65 because the benefits were good, and when it came time to think about retirement — and Medicare — she turned to a broker guide her through that maze.

The Margolises also found that it was cheaper to keep their private insurance, despite the sharp premium increase.

Jay Margolis takes Repatha, an injected medication that retails for $14,000 a year to control high cholesterol. Margolis is allergic to the lower-cost statins more commonly prescribed for people with high cholesterol.

Through a rebate program by the drug's maker, Amgen, he pays just $5 a month for the medication. But the program is available only to patients with private insurance — with Medicare, Margolis would owe a lot more every month for the drug, his broker, James Long, determined.

Another wrinkle for Margolis was the amount he would owe for Medicare's Part B premium, which covers medical services outside the hospital.

Regardless of whether you choose traditional Medicare or Medicare Advantage (in which benefits are administered by a private insurer), everyone pays the Part B premium. For most people, that will be $135.50 a month in 2019, but people with a high monthly income will pay more.

Jay Margolis concluded that the cost of his medication, plus the amount he'd owe for the Part B premium, made private insurance the better option.

But just recently, Amgen announced plans to slash the price of Repatha by 60 percent, to $5,850 a year, in response to slow sales, especially among Medicare-age customers. The change will send Margolis back to the broker's office to evaluate his options again.

Walker, of the AARP Public Policy Institute, said it's important to give yourself plenty of time to review your options. If you feel stuck, don't be shy about asking for help.

Every state has programs to provide free Medicare enrollment assistance. Independent brokers also can help, though it's important to understand how brokers are paid and whether they have incentive to recommend certain plans over others.

"It is a big decision, and there are a lot of choices," Walker said. "It's not surprising people have a lot of questions and are a little anxious about it."