The specific formula applies only for a first order RC low pass filter. This is derived from its frequency response:
The cutoff frequency is defined as the frequency where the amplitude of \$H(j\omega)\$ is \$1\over\sqrt2\$ times the DC amplitude (approximately -3dB, half power point).
Solve it for \$\omega_c\$ (cutoff angular frequency), you'll get \$1\over RC\$. Divide that by \$2\pi\$ and you get the cutoff frequency \$f_c\$.
If you know the frequency response of your filter, you can apply this method (given that the cutoff frequency is defined as above). Obviously, for high-pass filters for example, you calculate with the value for \$\omega\to \infty\$ as opposed to the DC value (always the maximum of the amplitude response, relative to which there is a 3dB decrease in amplitude at the cutoff frequency.)