Betty was basically seducing the grocery delivery boy. In the beginning of the movie Gilbert has no girlfriend so he doesn't really question Betty's motives for the seduction. He just enjoys being with this beautiful older woman. However, during the "burned cookies" incident Gilbert DOES have another woman he is interested in, Becky. So Gilbert is forced to evaluate his relationship with Betty. She tells Gilbert she could've had any other man, but she chose him. Gilbert replies by asking Betty why she chose him, and Betty replies "Because I knew you would always be there. I knew you would never leave.". This infuriates Gilbert because he does want to leave, but more over I believe he knows Betty is just using him. So Gilbert leaves. Its at this point (or sometime near) that I believe Ken Carver finally admits it to himself that Betty is having an affair. If Betty herself didn't outright tell him about the affair {She is acting almost as though she wants to be caught). And the combined stresses of his marriage, family, finances, and job simply overwhelm Ken and cause him to have a massive heart attack resulting in his drowning in the kiddie pool.
I believe Ken had no idea of the affair in the beginning of the movie. But later we see him catch Gilbert delivering groceries when he tips Gilbert. This gives Ken pause to think about what could be happening. Later, in the town diner, we see Ken catch Gilbert and mainly Betty locking eyes with each other while Ken pays his bill.I believe this is the moment Ken realizes the affair. Even though he might not want to admit it to himself, he knows. It seems Ken might have been trying to use Gilbert's guilt to pressure him into buying life/medical insurance when Gilbert came to his office. Ken then receives a phone call from Betty leading to the "burned cookies" scene. I believe if Ken had any reservations left they were removed after this incident. Which leads to Ken succumbing to a massive heart attack. And I believe Gilbert feels responsible and guilty for Kens death because of the affair.