1540s, probably from Old English wice "Applied generally or vaguely to various trees having pliant branches" [OED], from wican "to bend" (from PIE root *weik- (2) "to bend, to wind") + hæsel, used for any bush of the pine family (see hazel (n.)). The North American bush, from which a soothing lotion is made, was so called from 1670s. This is the source of the verb witch in dowsing.
1853 in the literal sense (witch-hunting is from 1630s), from witch (n.) + hunt (n.). The extended sense is attested from 1919, American English, later re-popularized in reaction to Cold War anti-Communism.
Senator [Lee S.] Overman. What do you mean by witch hunt?
Mr. [Raymond] Robins. I mean this, Senator. You are familiar with the old witch-hunt attitude, that when people get frightened at things and see bogies, then they get out witch proclamations, and mob action and all kinds of hysteria takes place. ["Bolshevik Propaganda," U.S. Senate subcommittee hearings, 1919]
in the sports sense, 1879, originally in cricket, "taking three wickets on three consecutive deliveries;" extended to other sports c. 1909, especially ice hockey ("In an earlier contest we had handed Army a 6-2 defeat at West Point as Billy Sloane performed hockey's spectacular 'hat trick' by scoring three goals" ["Princeton Alumni Weekly," Feb. 10, 1941]). So called allegedly because it entitled the bowler to receive a hat from his club commemorating the feat (or entitled him to pass the hat for a cash collection), but the term probably has been influenced by the image of a conjurer pulling objects from his hat (an act attested by 1876). The term was used earlier for a different sort of magic trick:
Place a glass of liquor on the table, put a hat over it, and say, "I will engage to drink every drop of that liquor, and yet I'll not touch the hat." You then get under the table; and after giving three knocks, you make a noise with your mouth, as if you were swallowing the liquor. Then, getting from under the table, say "Now, gentlemen, be pleased to look." Some one, eager to see if you have drunk the liquor, will raise the hat; when you instantly take the glass and swallow the contents, saying, "Gentlemen I have fulfilled my promise: you are all witnesses that I did not touch the hat." ["Wit and Wisdom," London, 1860]