At what distance should I keep the monitors from the walls?

Audio monitors and most of loudspeaker sets must be positioned distant from the walls. The reason is the first reflections coming from the near walls sum up with the direct one creating cancellations in the low frequency band (in technical words: notch or band stop filtering, due to counter-phase summation). Note it is a physical phenomenon.
The point is it attenuates frequencies positioned in the first piano octaves, which is an undesired aspect in high quality listening environments.
There are two solutions to face the problem: mounting the loudspeakers’ cabinets flush to the front wall or positioning them away from it, so that the cancellations occur at frequency lower than the one that is actually reproduced by the system (the loudspeaker system declared –3dB lower cut frequency).
Here is a simple formula to calculate the recommended minimum distance d between monitors and the wall behind them (the front wall, since you face it when listening to music), given the cut frequency fc in Hertz:

d>c/(4*fc) [m]

where c is the speed of sound (in standard condition we’ll use 344 meters /seconds) and d is calculated in meters. For the same reasons it will be important to keep monitors away from lateral walls, the distance will be at least three quarters of the one just calculated.

Often the space is not enough to respect these distances, a minimum of 90 cm is a good limit when working on speech: male spoken voice has its lower formants between 100 and 175 Hz and so we can avoid any troubles, in case of singing voices the limit raises to 1 m since the basso range begins at about F2 = 87 Hz.

I believe it is important to know this phenomenon exists and most of all being able of recognize it when working in control rooms. Beside using the typical empiric technique of listening to some reference albums, I advice a listening spot analysis through an impulse response measurement: a scientific approach permits to understand more what is generally perceived as a sensation and ameliorates both the sound engineer work and the exigent listener experiences.
Remember that the above are quick tips to avoid big mistakes, an accurate positioning must be actually studied considering the dimensions and the specific room’s acoustic treatment, making a series of impulse response measurements beforehand would permit to reach optimum as in professional environments.