Selecting pwm frequency for speed control of a dc motor?
As long as your PWM frequency is in the audible range (50 - 15000 Hz), there will be some audible noise. It doesn't mean something is wrong or about to break, simply vibrations at those frequencies propagate through air and can be heard.

If you absolutely want to get rid of the noise, you'll need a frequency of 20 kHz or more. L298 has a maximum commutation frequency of 25 kHz, so you should be able to get it working at 20 kHz (at least at 40-60% duty cycle) if your PWM waveforms respect that limit. Perhaps if you display your PWM signals with an oscilloscope, you'll realize why it didn't work.