Hi.
First thing to try would be to MUTE all line in, inputs, then unmute one by one, or try using rear ports vs front ports etc this will help decide if the problem is with soundcard, motherboard output ports or case phone jack
More info could be helpful, which headset? which case? which mobo? (for headphone jack location etc)
On one build not too long ago I got terrible buzzing on my Sennheiser headphones from a ROG front bay, but were perfectly silent from the rear headphone jack. and like you I knew the problem was grounding or EMI but couldnt get it quiet enough.