Elizabeth knows about the affair and does not deny that it happened. It is a source of tension between her and John throughout the play. She does publicly deny it though when asked.
John goes into the court proceedings to defend Elizabeth from Abigail's accusation of witchcraft. John aims to discredit Abigail by telling the court that she admitted to him that she and the girls were just having fun in the forest. They were not consorting with spirits. If necessary John is willing to discredit his own name in order to discredit Abigail. He would do this by admitting to the affair in order to prove that Abigail is not as pure and innocent as she claims to be.
Proctor, trembling, his life collapsing about him: I have known her, sir. I have known her. . .But it is a whore’s venge-ance, and you must see it; I set myself entirely in your hands, I know you must see it now.
The judges want to double check John's claim, so they ask Elizabeth if John was ever unfaithful. Elizabeth Proctor denies the affair to the judges presiding over the Salem witchcraft trials, because she doesn't want to destroy her husband's good name in the town of Salem.
Danforth, reaches out and holds her face, then: Look at me! To your own knowledge, has John Proctor ever committed the crime of lechery? 1n a crisis of indecision she cannot speak, Answer my question! Is your husband a lecher!
Elizabeth, faintly: No, sir.
Danforth: Remove her, Marshal.
Proctor: Elizabeth, tell the truth!
Danforth: She has spoken. Remove her!
Proctor, crying out: Elizabeth, I have confessed it!
Elizabeth: Oh, God! The door closes behind her.
Proctor: She only thought to save my name!