So mean and median both represent the central tendency of a data set. So when do we use median over mean?
Median is a more accurate form of central tendancy specially in scenarios where there are some irregular values also known as outliers. For example consider the below scenario.
Your father gets his blood pressure checked every week. But due some error in the device, the recording for one week was too high.
Mean vs median
So, for the above scenario we see the mean value deviates greatly from the regular blood pressure values due to a device error. Whereas the median value still accurately represents the central point of the data set. So under circumstances where there are outliers in the data set, median is a more effective measure of central tendency.