How I prevent bacterial infections caused by my child in putting his dirty fingers in his mouth?

Normal kid behavior. Kids often put their fingers into their mouths. That is normal behavior for children. The best that parents can do is to keep the children's environment fairly clean, and avoid places with obvious disease risks. A parent cannot constantly follow a child around and watch the child's hands, but giving the child gentle instructions every now and then is fine to do.
Wash hands often. Teach your child to wash his hands frequently. Every time after going to the bathroom, before eating, after playing outside or with a pet, whenever they appear dirty. Encourage him not to put the fingers in his mouth. Most children do this subconsciously, so mild distraction may help rather than directly telling him not to.
See below. Talk with him about good hygiene practices. And demonstrate good hygiene products.