Dogs' floppy ears tend to close the ear canal and create a moist, warm, dark environment that bacteria and fungi love to grow in. You can buy ear cleaning solution at the vet to help prevent ear infections and ask your vet to show you how to do it. Don't attempt to do it yourself without guidance because it can be incredibly painful for your doggy if you do it wrong, and you can make your dog become afraid of anybody touching his ears very, very quickly.
My vet also said that once the ears are infected, you can't use the regular cleaners because they really sting...
But if you go to the vet, most likely, they'll clean the ears out and if it's an ear infection, you'll get an antifungal, antibiotic solution that you have to administer 1 or 2 times a day for a week to 10 days. You have to be consistent with the treatment though, or you will get resistant bacteria and fungi and your doggy will have chronic ear infections.