As you have had the persistent cough now
for 3 weeks or so, I suggest you make an appointment to see your doctor to examine your throat and lungs and do a lung function test. If the doctor feels your cough is as a result of a bacterial infection, he will prescribe an antibiotic for you.
Having a cough is the body's natural way of trying to get rid of an irritant, whether this is a virus or a bacterial, dust particles, irritation by smoke and fumes etc.