What you have described it not a trick, nor is it illegal.
The first player has simply played an aerial pass to another defender. This is not a deliberate trick to circumvent the Law.
The second player has simply headed an aerial ball back to the goalkeeper, at a height that a player would be reasonably expected to head the ball. This is not a deliberate trick to circumvent the Law.
A deliberate trick to circumvent the Law would, for example, include, but not be limited to:
- a player flicking the ball up to their head or knee and then playing it back to the keeper with the head or knee, or
- heading or knee sliding the ball from off the ground back to their goalkeeper, that is, a position where playing it with the knee or head would be abnormal.
Any team that attempts the scenario outlined in your question this puts themselves at a considerable disadvantage. A poorly-skilled team would possibly fail to make a high pass at the right height, or the header would be difficult for the keeper to get to. This could see a loss of possession in their defending third.
At the highest levels of the game, even if the high pass was made perfectly and the header was directly to the keeper's hands, a defending striker would have a good chance of intercepting the high pass (since they generally move slower) or the header back to the goalkeeper. Either way, the defender making the header would be under significant pressure.
Deliberate trickery to circumvent the Law is rare enough that it is obvious when it occurs. Referees should not go hunting for it.