The British Armed Forces comprise the Royal Navy (RN), the army, and the Royal Air Force (RAF). The Royal Marines are treated as part of the Royal Navy for many purposes (unlike the USA, where the Marines are an entirely separate branch).
The Queen is the commander-in-chief of the Armed Forces. In practice, they are under the control of the Ministry of Defence, which was formed in 1964, replacing five separate ministries including the Admiralty, the War Office, and the Air Ministry. The office of Chief of the Defence Staff had already (in 1959) been created as the most senior military post over all the services, its first incumbent being Lord Mountbatten.
The Criminal Justice and Public Order Act 1994, which reduced the age of consent from 18 to 16, also legalised sex involving men in the Armed Forces, but with the important proviso that it could still be treated as grounds for discharge from the Armed Forces. So although they were no longer committing a criminal offence, servciemen (and women) who were discovered to be gay could still lose their jobs.
In 1999, Duncan Lustig-Prean and others, having been discharged from their services for homosexuality, won a case in the European Court of Human Rights. Following this ruling, the Defence Secretary, Geoff Hoon, announced that homosexuality would no longer be treated as an offence under service discipline. This came into effect in January 2000, without requiring any further legislation, and gay men and lesbians have since been entirely free to serve in the Armed Forces without having to conceal their orientation (unlike the USA, where "don't ask, don't tell" was in force from 1993 to 2011).