Standard Rule Is Three Inches
The rule of thumb from installation guides is that the cabinet space should be three inches wider than the oven. Measure height and width as well as depth of the oven and leave three extra inches in all directions.
Newer Ovens May Be Larger
Newer models are often larger than older ones. Although an old wall oven may be 30 inches wide, a newer model may be deeper and taller than the older model. Consider frameless cabinets for more efficient use of space.
If building a new kitchen, choose the wall oven model first and create a cabinet with three inch clearance all around. If replacing an old wall oven, carefully measure the space and look at the dimensions of new ovens online before making a decision.