How to Make It
In a medium saucepan, melt the 3 tablespoons of butter. Add the onion and cook over moderate heat, stirring occasionally, until softened, about 5 minutes. Add the beer, cover and cook over low heat until the onion is very soft, about 30 minutes. Drain the onion in a sieve set over a heatproof bowl; reserve the cooking liquid.
Transfer the onion to a blender and puree until smooth. Scrape the onion puree into a small saucepan and season with salt and white pepper.
Preheat the oven to 400°. Return the onion cooking liquid to the saucepan. Boil over high heat until reduced to 1/4 cup, about 3 minutes. Remove from the heat and add the lemon juice. Swirl in the 2 tablespoons of cold butter, 1 tablespoon at a time. Season with salt and white pepper.
Oil a 9-by-13-inch baking dish. Arrange the cod in the dish and drizzle with olive oil; rub the oil all over the fish. Season the cod with salt, white pepper and piment d'Espelette and sprinkle with the thyme. Bake for about 15 minutes, basting a few times with the pan juices, until the cod is just opaque throughout.
Gently reheat the onion puree and onion sauce; do not let the sauce boil. Spoon the onion puree onto plates. Set the cod on the puree and spoon the onion sauce on top. Serve right away.