If you are already drawing Social Security then you don’t have to apply at all. A person who starts Social Security prior to turning 65 will be automatically enrolled in Medicare 3 months prior to their 65th birthday.
For anyone who is not drawing Social Security then you will need to apply 3-4 months prior to turning 65. To enroll in Medicare you will need first get in touch with Social Security. They will take you through the process of setting everything up. You can work with Social Security via phone, online or in person.