For Medicare, apply through the Social Security Administration. For Medicaid, it varies by state but often through the state Medicaid agencies.