First of all, I am sorry to hear that you have been dealing with tinnitus (ringing) in your ears for the past few months. Let me start out by saying that to get a more complete answer to this question, I would recommend making an appointment with an ENT( ears, nose, throat...aka otolaryngologist
) to be seen and evaluated. They will perform a thorough ear examination, and also likely order an audiogram (hearing test). The reason being that there are many theories about tinnitus and its etiology, one of the most common taking into account that most patients with tinnitus have a degree of hearing loss.
The theory in basic terms is this; the brain has been used to receiving information about all of the frequencies of hearing all of your life, and when patients develop some hearing loss (usually high frequency in older age), the brain is no longer receiving that stimulus, so it tends to manufacture a sound of its own (ringing in your ear). This is why they will do the audiogram. There are many other reasons that one can develop tinnitus as well, which is why you will need a thorough exam to make sure that your ear anatomy is normal. As far as why this only happens when you exercise, I don't necessarily have a good answer. There is something called pulsatile tinnitus (tinnitus with your heartbeat) which might be exacerbated by exercise, but this is something that your ENT should sort out with you. Best of luck. Hope this helps.