Of course, raising one's hat has been a sign of respect, reverence, greeting etc for a very long time indeed. However, in the form of an exhortation/instruction, as in: "Hats off to John for organising all this" and similar situations - which I assume you are asking about - it dates back only to the 1970s.
Far be it from me to take issue with the venerable QM, but although the phrase is used in at least one 1970's song - 'Hats Off To Roy Harper' by the mighty Led Zeppelin, it is also included in 'Hats Off To Larry' which was a hit for Del Shannon back in 1961.
Not just raising the hat but taking it off , doffing it, is part of etiquette on occasions. When H.M. The Queen rides past in her carriage at Ascot this year the men will not just raise their toppers but take them off completely until she passes. There is even a procedure laid down for drill in the military when three cheers for someone are demanded; that too involves sweeping the cap or hat off, in strict time and movements.