Can your brain be affected by tooth infection?

It is possible. Our mouths are one of the portals to the rest of our body. Infections in the mouth and around the teeth can spread to the rest of the body. Of course, if you are young and healthy and have a good immune system, this isn't likely. It is the same for any other opportunity for disease to enter the body; through a cut, wound, nasal passages, etc. Just practice good hygiene to keep yourself healthy!
Affected? Maybe. Tooth infections are cited as some of the most intense pain known to people. In that regard, it could certainly affect how you operated day to day, so in a sense, yes, your brain could be affected. I would not say that your brain is at risk of being infected, however.