Often, seniors choose to enroll in Medicare when they are first eligible, at age 65, during their Initial Enrollment Period. Working seniors often delay enrollment until retirement, preferring to rely on health coverage offered through work or spouse coverage.
As long as you receive Social Security benefits, Medicare Part A is free, and there are no restrictions on when you can sign up. While many seniors enroll during Initial Enrollment, if you didn’t, that’s okay. You can enroll anytime during or after your Initial Enrollment period without penalty.
If you’re over 65 without Part B coverage when you retire and your employer-provided benefits come to an end, you may be entitled to a Special Enrollment Period, an 8-month period of time to join without paying a penalty. This starts at the end of the month you stop working or lose employer insurance, whichever comes first. To be eligible for a Special Enrollment, your company must have at least 20 employees. If they do not, then you will need to enroll during General Enrollment. And you may pay an increased premium, and a lifetime late enrollment penalty for each 12-month period of time you were eligible.
Retiring, Spouse Is Not
If you didn’t sign up for Part B because you had group coverage from an employer, that’s okay. Now that you are planning to retire, the same Special Enrollment applies and both you and your spouse will have a full 8 months without paying a penalty. If you retire but will be gaining group insurance coverage from your spouse, then you will still be covered under what Medicare defines as current employment and you do not need the coverage. Medicare does not classify COBRA and retiree benefits as current employment, and you will not be eligible for a Special Enrollment Period. If you are planning on taking retiree coverage from a former employer, you should enroll in Medicare.
https://www.cms.gov/Outreach-and-Education/Find-Your-Provider-Type/Employers-and-Unions/FS4-Medicare-for-people-over-65-nearing-retirment.pdf page 2, 3, 4