Plain and simple, Madame is the woman whom Julien flirts with into order to make Mathilde de La Mole jealous. And it totally works.
But along the way, we also learn about Madame, who the narrator says is:
"[…] not the constitutionally bilious type, simply swept into vengeance. Yet if, all the same, she likes doing harm, it's because she's unhappy. I suspect some inner misery. Might she be a moral prude who's weary of her profession?" (2.25.15)
Julien detects that beneath her prudish exterior, Madame de Fervaque actually yearns for a little passion in her life.
Breaking though Madame de Fervaque's defenses isn't the easiest thing in the world. It takes dozens of carefully crafted letters to do it. And even though Madame receives these letters well in private, Julien always finds her public behavior to be "almost a perfect example of patrician calm, which radiates an exact politeness and, even more, the impossibility of vibrant emotion" (2.26.2).
In the end, we're left to assume that this woman truly enjoys Julien's advances. But he goes back to Mathilde before we get a chance to see how this whole thing would play out.