The compression driver, used to feed midrange horns, consists of a compression chamber whose outlets are connected to the horn throat through a phase plug. The main challenge in the design of the phase plug is to avoid resonance and interference phenomena. The complexity of these phenomena makes it difficult to accomplish this design task manually. Therefore, we employ an algorithmic technique that combines numerical solutions of the governing equations with a gradient-based optimization algorithm that almost arbitrarily can deform the walls of the phase plug. A particular modeling challenge here is that visco–thermal losses cannot be ignored, due to the presence of narrow chambers and slits in the driver. Fortunately, a recent accurate but computationally inexpensive boundary-layer model is applicable and is here successfully used within the optimization loop. We use this model together with the so-called Cut Finite Element technique to avoid mesh changes when the geometry is modified by the optimization algorithm. Applying these techniques, the algorithm was able to successfully design the shape of a set of radially-directed phase plugs so that the final frequency response closely matches an ideal response, that is, one that is obtained by a lumped circuit model, ignoring wave effects.