1670s, shortened form of periwig. Meaning "person who wears a wig (professionally)" is from 1828. The verb meaning "to behave hysterically" (usually with out) is attested from 1955, from notion in to flip one's wig. Cf. dash my wig!, a former mild imprecation (1797), also wigs on the green (1856), Irish colloquial for "a fight or rumble" (because wigs are likely to get detached from owners in such an event).
A sleeveless undershirt worn by men •Fr regarding this as the attire of a male who would do this