It depends on the question you want to ask, more importantly from whose side you want to ask.
Lets take an example, what exactly do you want to know when you ask "what is the average salary of USA?", the underlying question that most likely you want to know is how likely I am to get this salary, in such case you are definitely asing the wrong question because only a few handful CEOs and top executives earning hundreds of million dollars in salary is pushing the national average high. Thats why median is a better metric for these. However if you were the government securities or treasuries wanting to know this, average wouldn’t be a bad metric for you.
Lets take another example, Now say you are launching a new product, you want to estimate the revenue each user brings in to your site . A common metric in such case used is “average revenue per user”, mainly because here the underlying question is how much more can my company earn, look now you stand on the other side and want to have an aggregated view.
To summarise the above two examples, if you yourself view it as a sample of the data your interests would be towards the median, whereas if you are a aggregator your interests would align toward the mean.
Now say if you are none, you are just a statistician want to portray both sides of pictures. Use median when you are not sure of the distribution of the data. 85% of natural data sets have been found to be skewed and more than 99% to have some sort of outliers. Median is robust to both skewness as well as outliers. Hence median has been by default the more popular choice to measure central tendency than mean.
However if you are very sure that your data is not skewed at all and has near perfect bell shaped distribution, you can use mean. But mind you median in this case too won't be too off from mean. So if you are new to statistics you can blindly go for median for just about everything.
As some answer already mentioned mean can be more useful in predictive problems and normalized sum problems but when it comes to a group representative selection use case nothing beats median which is what I tried to exemplify in the first couple of paragraphs of my answer.