Why have I had ringing in my ears for 3 weeks?

Tinnitus . Tinnitus has several causes, originating both within the ear and also in regional structures near the ear. "ringing" is usually a high pitched tone associated with hearing loss, but could also be due to other causes such as blood pressure changes, diabetes, temporomandibular joint inflammation, abnormalities in blood flow, and eustachian tube dysfunction. An audiogram and ENT exam are recommended.
Virus. It maybe related to a viral infection of the inner ear. However you should see an ENT or a neurologist to check for other causes.