Is there a legal requirement to tell your doctor you are a pilot?
In the US, you are not required to inform a doctor that you are a pilot. However, on the application for a medical certificate (Form 8500-8) you must list all "visits to health professionals" in the last three years, including type of professional and the reason for the visit.

The medical examiner uses that information to guide questions to ask about your medical history: a yearly checkup with your family doctor will not be remarked on, while a visit to a specialist might invite scrutiny about that area of your medical status. Depending on any existing conditions, you may need a letter from your primary doctor explaining your condition, but you would specifically ask for this rather than expect it to be provided.