When I export MIDI files as *.wav or *.mp3, the glitches are still there, but of course, now they occur in exactly the same place each time.
OK so that means that the problem is almost certainly in the digital realm. If it were an electrical problem with connection between your interface and speakers for example, it would not occur on an export.
btw you are not exporting MIDI files. MIDI files are data that are used to control the synth. What you are exporting are audio files.
You may be able to learn quite a bit by looking at those audio files inside Sonar. If you zoom in on the wave form, you can look at individual samples. Digital clipping will show as a flattening of the peak when the abnormal sound occurs. Dropouts will often show as a break in the continuity of the wave form.