How often is it ok to give a 5 month old Tylenol?

My baby has an ear infection and is on an antibiotic. His doctor said I can also give him Tylenol for the pain. Over the past 3 days I have given him Tylenol about twice each day more than 6 hours apart. One of the days I think I only gave it to him once. I was just wondering how long is it ok to give him Tylenol for?