Teresa shows up in Disgrace as one of Coetzee's many historical and literary references, which is totally reasonable since she was the mistress of one of the poets that David both researches and teaches in his course. When David begins his opera on Byron, however, Teresa takes on a life of her own beyond mere historical reference; she essentially becomes a character in the novel.
Initially, Teresa provides a starting point through which David can explore the themes of love and sex in his opera. But then Coetzee does something sneaky – he makes Teresa a lens through which we explore David's changing attitudes toward love and sex. Initially, David hopes to write an opera about the lustful affair between Byron and Teresa in Italy. He forms this plan, incidentally, while he still thinks that the younger ladies are fair game to him. Here's what the narrator has to say about the initial plans for the opera:
That is how he conceived it: as a chamber-play about love and death, with a passionate young woman and a once-passionate but now less than passionate older man. (20.48)
Um, so, is this opera really about Byron and Teresa, or is David writing it about someone else we know? (Hey, Melanie's a drama student. If she could sing opera, maybe David could entice her with a sweet leading role. Then she could play someone exactly like herself!)
As time progresses, however, David starts changing his mind about the way he wants the opera to look. Rather than staging his opera during the actual affair between Byron and Teresa, he decides to make it a retrospective from Teresa's point of view, long after Byron has died and when she's in the throes of middle age. Let's take a look at the new, aging Teresa:
The passage of time has not treated Teresa kindly. With her heavy bust, her stocky trunk, her abbreviated legs, she looks more like a peasant, a contadina, than an aristocrat. The complexion that Byron once so admired has turned hectic; in summer she is overtaken with attacks of asthma that leave her heaving for breath. (20.53)
Does this new Teresa remind you of anyone we know? Maybe someone whose name rhymes with Dev Zaw? If David resembles Byron, then the person who resembles Teresa represents David's own romantic interests. While we won't go so far as to say that David's feelings towards Bev are at all romantic, they nevertheless show that he's maturing a little bit. David charges himself with the task of loving this new older Teresa in his opera, and perhaps he does so as a way of transitioning from loving the younger ladies (which heretofore has just brought him scandal and misery) to seeking out older, wiser, and perhaps more down-to-earth women.