Your question is based on the faulty premise that only one country can apply jurisdiction at a time. In fact, many states may have or claim to exercise jurisdiction simultaneously. In that case, all that really matters is whose judges you end up in front of first.
To tidy this matter up, the Tokyo Convention limits how many jurisdictions apply.
The Toyko Convention provides as follows.
- The State of registration of the aircraft is competent to exercise jurisdiction over offences and acts committed on board. (...)
The criminal jurisdiction of a State in whose airspace the offence was committed, if such State is not the State of registration of the aircraft or the State where the aircraft lands, shall not be exercised in connection with any offence committed on an aircraft in flight, except in the following cases:
(a) if the offence has effect on the territory of such State;
(b) if the offence has been committed by or against a national of such State;
(c) if the offence is against the national security of such State;
(d) if the offence consists of a breach of any rules and regulations relating to the flight and manœuvre of aircraft in force in such State;
(e) if the exercise of jurisdiction is necessary to ensure the observance of any obligation of such State under an international agreement.
As you can see the Convention is drafted very widely to allow the State in every other respect to exercise jurisdiction. In practise, that means for your question:
Country C can certainly apply their criminal and civil law to the aircraft as they deem fit. Country B is entitled to apply its laws as provided by above. If the aircraft is registered in country D then country D may also apply its laws in any respect to the aircraft as it deems fit.
Let's look at an example.
The United States neatly creates the "United States Special Aircraft Jurisdiction" to cover aircraft in flight. (The US Congress uses their authority derived from the interstate/international commerce clause in the US Constitution to create this jurisdiction.)
This is how it is defined.
(2) “special aircraft jurisdiction of the United States” includes any of the following aircraft in flight:
(A) a civil aircraft of the United States.
(B) an aircraft of the armed forces of the United States.
(C) another aircraft in the United States.
(D) another aircraft outside the United States—
(i) that has its next scheduled destination or last place of departure in the United States, if the aircraft next lands in the United States;
(ii) on which an individual commits an offense (as defined in the Convention for the Suppression of Unlawful Seizure of Aircraft) if the aircraft lands in the United States with the individual still on the aircraft; or
(iii) against which an individual commits an offense (as defined in subsection (d) or (e) of article I, section I of the Convention for the Suppression of Unlawful Acts against the Safety of Civil Aviation) if the aircraft lands in the United States with the individual still on the aircraft.
(E) any other aircraft leased without crew to a lessee whose principal place of business is in the United States or, if the lessee does not have a principal place of business, whose permanent residence is in the United States.
("In flight", by the way, means basically between the doors being closed after boarding until they get opened again. See the link for the full definition.)
So does that mean you can't drink under 21 on an aircraft overflying the US?
No, because there is no law against drinking in the Special Aircraft Jurisdiction of the United States. For the full list of crimes that exist in that jurisdiction, see chapter 465 of the US Code (in particular https://www.law.cornell.edu/uscode/text/49/46506).
A similar provision exists in UK law. Unfortunately UK law is a lot more opaque than the neat US definition. It is expressed as follows.
Any act or omission taking place on board a British-controlled aircraft or (subject to subsection (1A) below) a foreign aircraft while in flight elsewhere than in or over the United Kingdom which, if taking place in, or in a part of, the United Kingdom, would constitute an offence under the law in force in, or in that part of, the United Kingdom shall constitute that offence. (...)
For the purpose of conferring jurisdiction, any offence under the law in force in, or in a part of, the United Kingdom committed on board an aircraft in flight shall be deemed to have been committed in any place in the United Kingdom (or, as the case may be, in that part thereof) where the offender may for the time being be.
The Act is not a good piece of Parliamentary draftmanship. But basically, if you are found in London, English law will apply to you when committing a crime over the Indian sea on a British aircraft.
So what happens if two laws are in conflict? Well, very pragmatically it depends where the plane lands and who arrests you. If you appear before a US federal judge, they will apply the US law as it is clearly written. Their duty is to uphold their law, not obey anyone else's.