"to strike sharply," 1719, probably of imitative origin. The noun is from 1737. The word in out of whack (1885) is perhaps the slang meaning "share, just portion" (1785), which may be from the notion of the blow that divides, or the rap of the auctioneer's hammer. To have (or take) a whack at something "make an attempt" is by 1820 (with have), 1845 (with take). Wack or whack "crazy person," 1938, is probably a back-formation from wacky, which probably comes from the blow-on-the-head verb. Related: Whacked; whacking. Whacked out is from 1969.
Wack, whack in the slang sense of "unappealing; crazy," hence "worthless, stupid" is by 1986, apparently popularized by an anti-drug slogan crack is wack.