Can you use cortisporin (neomycin polymyxin and hydrocortisone) to prevent an ear infection?

No. Ear infections happen behind the ear drum. Cortisporin (neomycin polymyxin and hydrocortisone) won't penetrate past the ear drum and so it does nothing for the middle ear.
Yes but why? Using ear drops to "prevent" an ear infection is not wise. You are using a prescribed medication (likely left over) to prevent something that can be prevented without it. When you mention "ear infection, " i presume you mean an outer ear (swimmer's ear). This is best prevented by keeping water out of the ears or if water does get in the canal a couple of drops of rubbing alcohol will do the trick.