In the UK, the wreckage of military aircraft and designated military vessels is protected under the Protection of Military Remains Act 1986. Only 12 vessels are currently designated as controlled sites meaning that diving is banned without explicit permission in the form of a licence from the Secretary of State. Those controlled sites are:
- HMS Affray
- HMS A7
- HMS Bulwark
- HMS B2
- HMS Dasher
- HMS Exmouth
- HMS Formidable
- HMS H5
- HMS Hampshire
- HMS Natal
- HMS Royal Oak
- SM UB-81
- HMS Vanguard
Note that three of these, HMS Affray (sank 16 April 1951), HMS A7 (sank 16 January 1914), and HMS B2 (sank 14 October 1912), were accidental losses in peacetime, and are thus technically not "war graves". Note also that the German submarine SM UB-81 (sank 5 January 1918) is included in the list.
There are 79 wrecks currently designated as protected places. This means that diving on those wrecks is allowed but divers cannot interfere with the wreck sites. In other words, divers can look, but mustn't touch. I have dived some of these wrecks myself.
If you are interested, the latest Statutory Instrument listing the sites and wrecks covered by the act is The Protection of Military Remains Act 1986 (Designation of Vessels and Controlled Sites) Order 2019. Protected places are listed in Schedule 1, and Controlled sites in Schedule 2.
All other wrecks in UK territorial waters are free to dive - even those sunk during times of conflict. However, the normal laws governing ships lost in UK territorial waters will apply.
The British Sub-Aqua Club also has a general Respect our wrecks policy, covering all wrecks in UK waters, that discourages souvenir hunting by divers.
In response to the comment by Panzercrisis below.
The protection given to vessels commonly referred to as "war graves" actually has nothing to do with the presence or absence of human remains, or munitions or anything of that sort. (If it did, those same protections would logically apply to many civilian ships lost at times when countries were not at war, and where there was a great loss of life - the Titanic, being just one well-known example).
The protection relates to the laws of marine salvage, and - frankly - those are a mess.
The protection for the kinds of wrecks often referred to as 'war graves' comes from The International Convention On Salvage, 1989, and falls under the jurisdiction of the International Maritime Organization.
Specifically, Article 4 - State-owned vessels, prohibits the salvage of:
"... warships or other non-commercial vessels owned or operated by a State and entitled, at the time of salvage operations, to sovereign immunity under generally recognized principles of international law unless that State decides otherwise."
NOTE: It doesn't prevent you from diving on the wreck (assuming the wreck is shallow enough to be dived on). It simply prevents you from removing anything from the wreck site.
The protections granted by the Protection of Military Remains Act 1986 cover specified wrecks under UK jurisdiction, and are over and above those provided under the International Convention On Salvage, 1989.
There is also the UNESCO Convention on the Protection of the Underwater Cultural Heritage, 2001 which gives protection to "underwater cultural heritage" that has been "submerged continuously or partially for 100 years". Thus, where the convention applies, wrecks from the First World War would be protected, but those from the Second World War would not.
At the time of writing, the convention has not been ratified by the UK government (or by the US government).
Battlefields, on the other hand, are frequently privately owned. Many farmers will allow you to walk on the sites of former battles which were fought on the land that they now own, but it is still private land. You do not have an automatic right to walk there.
Where the sites of former battles are publicly-owned, there may still be restrictions that prevent you from "freely visiting" the site. Sometimes, these restrictions are there to protect the site. On other occasions, they may be intended to protect you! (Example: Verdun).
Incidentally, I have dived on dozens of shipwrecks where people died. Some of those were what we would commonly call "war graves". I have never seen human remains while diving on any those sites. Personal artifacts like boots, belts etc., are sometimes found (tanning leather gives it some protection), but not the people themselves.
By and large, where they were fairly easily accessible, human remains tend to have been consumed by marine animals or buried in the silt. Where remains do survive, they tend to be deep within the structure, and only recovered during salvage, or archaeological recovery work (like those recovered from the Mary Rose).
(You should also be aware that deep-penetration dives into wrecks are incredibly dangerous, especially so in relatively deep water).
By contrast, I have seen what were almost certainly human remains in the plough soil on every visit I have made to the Western Front battlefields (I reported it the first time. The response was essentially "and what do you expect us to do with a single distal phalange...?". After that, I simply left them where I found them).