There are three categories of medicines in the UK. Those that have to be prescribed by a doctor, those that have to be sold under the supervision of a pharmacist, and those that are freely available (and as such can be bought in supermarkets and newsagents etc.).
NHS prescriptions for medicines are charged at a fixed rate (£6.30 at time of writing). However, if you are under 16, a pensioner (men over 65, women over 60), or a student under 19 then you are entitled to free prescriptions. You can also receive free prescriptions if you are pregnant (or have had a baby in the past year), have a permanent disability or certain medical conditions (such as diabetes), or if you are on a low income receiving state benefits.
The timetables of chemists are posted on their doors and in local newspapers. In emergency, if you need medicine when all pharmacies are shut, then you can contact your GP or local police station.