reduce harmonics produced by microcontroller
No, you need a low pass filter aka reconstruction filter.

In the general case your filter needs to reject everything at or above Nyquist = Fs/2 = 22.05 kHz. Typically it might have have a roll-off from say -3 dB at 20kHz to -80 dB at 22 kHz. This would be quite a demanding filter to implement with analogue components however, so if you are really only interested in generating a single tone at 18 kHz then you can use a less aggressive LPF which has a -3 dB point at say 20 kHz and a stop-band which begins at 35 kHz.