You just have to punish her for brining him up and she'll never do it again.
For example
I had this chick laying in my bed the other night, she says " I know guys hate it when girls talk about other guys but this my on my mind.... My ex boyfriend..." I said(really sarcastic) " hold on, let me pull up an chair. I guess it's time to play Dr.Phil" ( I go grab my computer chair; pull it in front of her and sat down in it with my legs crossed an said " now what seems to the issue". Her face got red, she got upset. I grabbed her and kissed her and havent heard a word about him since. Except when he started blowing up her phone while we were having sex that night. *Shrugs*
