I’m certain that people recognized clusters of similar illness within small communities well before they had anything like a germ theory of illnesses. So we can’t possibly know what the first instance was.
In ancient Greece, Hippocrates examined the relationships between the occurrence of disease and environmental influences. He used the terms “epidemic” and “endemic” to distinguish between diseases that are “visited upon” a population (epidemic) from those that “reside within” a population (endemic). The term “epidemiology” appears to have first been used to describe the study of epidemics in 1802 by the Spanish physician Joaquín de Villalba in Epidemiología Española.