If the problems continue (and it’s possible to use another cable with your speakers or headphones), then try replacing the cable. If you still hear the unwanted noises, your PC is likely to blame.
You can perform the same test in reverse, too: get another set of speakers or headphones and plug them into your PC. Note that it’s perfectly normal to hear pops and buzzes as you disconnect the audio jack and plug it into something else, but if you continue to hear electronic interference even after plugging it in, you can rule out your PC as the problem. To see if the speakers are the problem, simply plug them into an audio source other than your PC-like a phone or an MP3 player. It’s easy enough to nail down which part of your speaker setup is at fault. Broadly speaking, we can break them down into three categories: problems that originate from the physical speakers, the cable connection, and from the PC itself. Luckily, the most common issues are fairly obvious. There are dozens, maybe hundreds of explanations for unwanted sounds coming from your speakers.