These two words have confused enough people over the centuries that they have become somewhat interchangeable.
When referring to a frame that holds and stores things (such as a magazine rack), always use rack. When you are wracked with pain, or you are racking your brain, either use is acceptable. Racking is probably more common, though preferences may vary for North American and British spelling.
As a noun, wrack can mean seaweed and other debris that accumulates on beaches; as a verb, wrack has a similar meaning to wreck.
Commonly used phrase: wrack and ruin
The neighborhood has gone to wrack and ruin since I left.
wrack
We searched the beach wrack for interesting seashells.
Bladder wrack (also bladderwrack) is a good source of iodine.
A careless driver, he wracked his new car within a week of purchasing it.
rack
“I’ll pick up a rack of lamb for the party,” Henrietta told her husband.
“Please place these brochures in the rack on the wall.”
“Rack ’em up!” Jared said as he grabbed a pool cue.
“I’ll rack my brain until I remember that woman’s name!”
The rack was an early instrument of torture used to extract information and confessions.
racking
Driving in a blizzard is a nerve-racking experience.