A:"This lesson was so boring, the teacher has been talking/was talking all the time.
B: "How would you know, you have been sleeping/were sleeping all the time".
If the lesson had just finished and we were heading out which would be better?
No need for 'this!' If A and B are talking about some lesson that has just finished, you can use 'the.' However, note that if you are using past tense, 'that' is used and not 'this.'
has/have been is used to talk about an action that has some starting point and it is continued even now. This is not the case here. So,
A: The lesson was so boring, the teacher was talking all the time
B: How would you know? You were sleeping all the time!