You can receive necessary medical care in the country you are visiting on holiday, but only if it is an EU/EEA country or Switzerland or the United Kingdom. You will receive that care in accordance with the rules that apply in the country you are visiting.
On the European Commission website you can find out what medical care is refunded in each country. You will also find information on what you need to do to obtain a refund.
Please note: Are you travelling to another EU country specifically for medical treatment? If so, you cannot use your EHIC. In such a case you need to ask the health insurance fund in your country of residence for permission first.