When a divorce is the result of one parent having an affair, you have a lot of decisions to make. One of these is whether they are going to tell the children or not. This is a serious decision that must take the child's maturity level into account.
Around 40% of all marriages have been impacted by infidelity. Many of these will end in divorce; however, other couples opt to work things out and try to move forward. If you and your spouse are working on the marriage, there likely isn't any reason to tell the children.
One exception to not telling the kids about the affair if you're going to work on the marriage is if the person the parent was having an affair with is someone the children have regular contact with. More than likely, that contact will be eliminated, so the kids may want to know why.
The time when you may consider telling the kids is when the marriage is ending. One factor you need to think about is whether they will hear about it from another source. If you think they will, it might be best to provide age-appropriate information.
You may also need to discuss the situation with them if the affair isn't going to end. When the relationship is going to continue, the children may need to know so they can cope with the major changes that are coming.
If you decide to end the marriage due to the affair, you need to focus on trying to get the best settlement you can. You also need to think about the child custody arrangement and how it might impact the children.