Doctor vs. médico

In Spanish language, both 'doctor' and 'médico' are terms used to refer to a doctor or physician. The use of these two words can quite often be interchangeable; however, there are certain contexts where choosing one over the other becomes more appropriate.

Doctor

This term is derived from Latin and originally it referred to a teacher or someone who was authorized to teach. Currently, in Spanish, 'doctor' is often used to refer to a person who has achieved the highest degree in university education, not only related to medicine but any field. That said, it is frequently used as well for medical doctors.
El doctor en física está dando una conferencia.
(The doctor in physics is giving a lecture.)
Mi doctor me recomendó hacer más ejercicio.
(My doctor recommended me to do more exercise.)
Fui a ver al doctor por mi dolor de espalda.
(I went to see the doctor for my back pain.)

Médico

'Médico' is specifically used to refer to a medical practitioner or a physician. It does not designate any academic achievement and is solely associated with the medical profession.
Mi médico familiar es muy amable.
(My family physician is very kind.)
La médica me dijo que necesito descansar.
(The doctor told me I need to rest.)
Podemos conseguir un buen médico en ese hospital.
(We can get a good doctor at that hospital.)

Summary

'Doctor' and 'médico' can often be used interchangeably when referring to a medical doctor, but 'doctor' has an additional implication of high academic achievement and its use extends beyond the medical field. On the other hand, 'médico' emphasizes specifically the profession.