Everybody does all their lines, all the time, no matter who the shot is focussed on & even if one actor is completely out of shot; they will still stand on their mark & deliver their lines.
This gives each performance a better chance of being the same as the last angle - the director, once [s]he's happy with the actors' performance, is then likely to want them to repeat it identically each time after, to get all the required shots for the scene.
In extreme cases, a stand-in may be used for the 'back of an ear' shot, though that is less likely in a large dialogue scene where real interplay between characters is required.
Once the actors are doing their bit accurately, then the actual important stuff* of getting the camera angles, moves & lighting right need time to do their part too.
As the final scene is likely to intercut between [at least] 2 angles**, the sound team at the cut will choose which take to use & then will likely use that take for the entire scene, or at least entire dialog of one character [not always, but to keep this explanation simpler].
That will mean that for whoever has their back to the camera at any given time, you are not hearing what they said on that take, but on the one where the camera was facing them. That's so the lip sync doesn't need to be adjusted for the face-on shot.
In news footage & interviews, the shot of the back of the reporter's head whilst the interviewee is speaking is known as doing 'noddies' - though I've not heard the same term used in film/TV drama.
*To the rest of the crew, actors are little more than movable scenery that instructions can be given to which they are then expected to repeat until told otherwise. The only person whose job it is to be interested in how well the actors are acting is the director - everybody else has a different job, that they need to get right.
**Often, the way the order of shots is done is to give the actor with the most emotional effort the last shot rather than the first...
So they would do, for instance, a wide, capturing the whole scene, then come in tighter to pick up the reactions of supporting characters, then secondary characters & less-involved principals, then finally round to the main shot[s] of the principal. This gives them chance to warm up for the emotion & get the lines firmly embedded, without being centre-frame too soon & risking burning out before the scene is in the can.