What are the parameters of choosing of right PWM frequency for a system?
There are a number of parameters:

1) Power level and voltage.  Generally the higher the power level and voltage, the slower you can switch.  This is limited by switching losses.  MW class system switch at a few kHz.  This is slowly changing now with wide band-gap devices such as silicon-carbide.

Low-voltage IGBTs and MOSFET (~ 1000 V) can switch around 20 kHz.

Low-voltage MOSFETs can switch in the 100 kHz range.  GaN devices have no problem going to the MHz range.

2) Passive filter size. The faster you switch, the smaller the passive filters have to be.  This applies to solar inverters/wind inverters/dc-dc converters.  Motor drives are not required to switch that fast because the motor winding has large impedance anyway.

3) Dynamic performance. For motors, one needs to make sure that the torque (=current) can be controlled with reasonable dynamics.  The faster the switching the faster the motor control and therefore better dynamic behavior.  However, this results in higher switching losses, larger heatsinks, and larger cost.  Typical motor winding current ripple is &lt; 10% of the nominal current for most middle-performance motor drives so that should be the starting point for calculations.

It's really all about trade-offs.