No, I don't believe hereditary has anything to do with infidelity. Children do however observe their parents' behavior and surrounding environment. We (learn) moral behavior and decide from there. Our natural inclination is to do what makes (us) happy. Children have to be (taught) to (share, love, sacrifice to achieve a goal, and be considerate of others). It’s not something that is "automatically" passed down through heredity.
At the end of the day monogamy is not something that is "programmed" in our DNA. Monogamy is an individual "lifestyle choice" much like wanting to be single or married. For some people monogamy is difficult because they lack the discipline to follow a "strict diet" or they bore easily. A person has to "commit" to monogamy.
However by the same token circumstances may change someone's mind. The underlying assumption that causes someone to "forsake all others" is the belief that one has a mate who is there for their mental, physical, and emotional needs. If someone has no food at home they will go out to a store or restaurant to eat.
The key to any successful relationship is to find someone who shares your same values.