There are some language guides, generally the ones that pay a lot of attention to the etymology of “rack” and “wrack”, that will still say it is “racking your brain” not “wracking your brain”, but these are becoming few and far between. In fact, people have been confusing “rack” and “wrack” almost as long as the two words have existed. For instance, some of the earliest known uses of the expression “wrack and ruin” (circa 15th-16th century) were using the technically incorrect “rack and ruin”. The first known instance of this was from Thomas Fowler’s History of Corpus Christi College (1599).
In order to see why it technically should be “rack your brain”, we have to look back at where these two words come from. The word “rack” probably comes from the Middle Dutch “rec”, meaning “framework”, and is a cognate of the Old English “recken”, meaning “to stretch out”. This lent itself to the Middle English word for a frame that you put things on to dry or to stretch something out on (as with leather working). Shortly thereafter, the word also came to mean a frame for putting people on to torture them. This in turn gave rise to the even more expanded meaning of causing mental or physical harm or suffering. Over this same span, several other distinct definitions of “rack” sprung up, including the most pertinent one for this discussion, “to stretch or strain”.
“Wrack” probably came from the Middle Dutch “wrak”, meaning “wreck”, which eventually gave rise to “wrack” as in “shipwreck” and “wrack” as in “damage, destroy”. This soon extended to meaning any flotsam, jetsam, seaweed, etc. washed up on the beach, which in turn gave rise to the definition “state of disrepair or decay”, hence the expression “wrack and ruin”. As with “rack”, several other definitions have popped up, often synonymous with “rack”.
You can see from this why linguists who put a lot of stock into the etymology of a word over current accepted definitions would say that “wrack your brain” would be incorrect as you aren’t meaning “to bring your brain into a state of decay or disrepair” or to “wreck your brain”. You’re meaning to strain yourself mentally in order to remember something. You can also see from these two etymologies why the first known instance of racking brains uses “rack” instead of “wrack”:
They rack their brains… they hazard their lives for it. -William Beveridge’s Sermons (1680)
However, given that people have been writing this expression (and many others that use “wrack” and “rack”) both ways nearly as long as the expression has commonly existed, the bottom line is that you aren’t going to go afoul of many English language guides if you write “wracking your brain” instead of “racking your brain”. But if you really want to make sure you’re toeing the line (and avoid the wrath of internet Grammar Nazis), use “rack your brain” not “wrack your brain”, particularly if you are writing for British English readers.
On that note, as a general rule, quite often when you aren’t sure whether you should put “wrack” or “rack”, “rack” probably includes a definition for what you mean, while “wrack” doesn’t necessarily do so. Thus, as the New York Times Manual of Style recommends, consider eliminating “wrack” from your writing vocabulary and just always use “rack” unless you’re using “wrack” to mean “wreck” or “to inflict damage”. In the former case, just use “wreck”. In the latter case, use “wreak”.