On occasion, when the computer runs, a noise emits out of my computer. It doesn't make the noise constantly, but only when I boot certain programs, specifically Visual Studio Code or PyCharm. This sometimes happens when I'm running Ableton as well. That being said - I'm not entirely sure if the Optiplex 390 just has some peculiar sounding fans or if I'm just looking into it too much. The audio isn't that great on this video I took but if you put the volume up, you can faintly hear it. https://vimeo.com/230839760
It's possible the CPU and/or GPU fan is running at higher speed when you use those apps because they probably need a lot of computing power which generates heat. The noise might be a fan itself, or maybe something is just vibrating when a fan runs at higher speed...
You might want to open the PC (power off, unplug and press/hold power button for ~15 sec first) and see if all fan blades are clean and turn freely. Use canned air to blow out all the dust bunnies., and make sure nothing is touching any of the fan blades.
Some people listen through a cardboard (not metal!) tube to isolate the source of a noise like that. But you have to be very careful if you boot the PC while the case is open, and you do this at your own risk.