"If his cyst was caused by past kamma, and if his bad behavior is
caused by the presence of the cyst, then this implies that his present
behavior is caused by his past kamma and he has no control of it. Is
that true?"
He has control of his present behavior, but he doesn't have control due to ignorance. The bigger the ignorance, the less control of behavior he has.
It is not the cyst that is preventing him to have control of his behavior. It is ignorance. Let me put it this way so you can understand:
Suppose a child is born. Suppose this child, due to good kamma, can live a very long life. Suppose this child, due to bad kamma, is born with a cyst. Due to the cyst, he harms others. Suppose every time he harms another being, that being harms him back and causes him immense suffering. Suppose the child is harming others every time he sees a being, no matter what that being is. Suppose his parents take care of him and teach him how to get water, food and shelter. The child grows up into adulthood harming others and feeling immense suffering of his body due to others harming him in retribution to him harming others. The child harms others 10 years and feels immense suffering of his body due to his harming others. He harms others 20 years, 30 years, 40 years, 50 years ... all these years feeling immense suffering of his body due to him harming others. What do you think, would this child harm others more or less, after 50 years of harming others and feeling immense suffering of his body due to others harming him in retribution to him harming others? He would harm less. Why? Because he learned that by harming others he would feel immense suffering of his body, thus he decides not to harm others.
The story above is an extreme example, but this is exactly how beings get rid of ignorance. This same mechanism is at work all the time, be it in a subtle, non visible way (examples are diseases of the body and/or mind, or normal feelings of anger/sadness to disturbing/sad events), or an obvious, visible way (example is criminal behavior, having failed relationships in adulthood, compulsive lying, drug/alcohol/other addictions).
"If his bad behavior was caused by the presence of the cyst, then
would Andrew be creating bad kamma (by attacking the girl) due to bad
intention, or would he not be creating bad kamma (by attacking the
girl), because it was due to the cyst and not due to his own
intention?"
Andrew was creating kamma.
Was he creating bad kamma? Probably yes. How much bad kamma? We can't know for sure. It all depends why he acted upon his intentions to harm others.
Once the cyst was removed, he stopped harming others. Thus, he could see that he acted harmfully due to wrong views, thus, his bad kamma created while he was still having the cyst, has exhausted.
"What did the Buddha teach about the physical body (including brain)
and its ailments or conditions, affecting the mind and kamma?"
He taught that from ignorance, there comes birth. From birth there comes diseases (ailments or conditions affecting the mind) and intention (kamma) and all the rest.
Please be aware that "birth" does not mean literal birth as we understand it. Also, "birth of being" does not mean literal being with a physical body as we understand it. It could be any birth, any being, any physical or non-physical body ... what is meant by birth, is merely a birth of self - the 5 aggregates. These 5 aggregates could be in any combination. The combination depends on ignorance.
"How do we avoid bad kamma, due to mind-influencing effects caused by
physical conditioning?"
There are times when we can't avoid bad kamma, due to ignorance. In such times we have to experience this bad kamma through suffering in order to learn how to avoid it in the future. In this way we are eradicating ignorance and gaining wisdom. When ignorance is eradicated enough, complete liberation from suffering can be attained.
"How could Buddhist teachings help a person like Andrew (before his
cyst was removed)?"
I think hardly. If he is not able to grasp the teachings, he would not follow the teachings. Sometimes there is nothing that can be done to liberate a being from suffering in his former life. It is not your fault, nor the fault of the being, nor anybody's fault.