You wreak havoc, wreak revenge, or wreak damage; wreak is a verb, and havoc is what follows it. Wrack is a noun meaning ruin or wreckage, closer in feel to wreck than to wreak. The set phrase is always wreak havoc, never wrack havoc, even though wrack looks like it should fit.
The core difference
Wreak is a verb meaning to cause or inflict something damaging; wrack is a noun meaning ruin, destruction or wreckage.
- wreak — to cause or inflict something damaging or violent: The storm wreaked havoc on the coastal town.
- wreak — to inflict revenge or punishment: He wanted to wreak revenge on the people who had wronged him.
- wrack — ruin, destruction or the remains of a wreck: The old pier was left in a state of wrack after the flood.
How to tell them apart
The confusion mostly comes from one phrase: wreak havoc. Because wrack sounds like wreck, and wrecks and havoc go together in people's minds, writers often reach for wrack havoc by mistake. The correct verb is wreak, from an old word meaning to drive out or punish, and it takes havoc, revenge or damage as its object.
Wrack itself is a noun, not a verb you do something with in this phrase. It names the ruin or wreckage left behind, so you might describe something as being in a state of wrack, but you do not wrack something the way you wreak havoc on it.