My daughter talks to his boyfriend in class on her phone and I don’t know how to discuss this with her
Cut her off then. I assume you pay for her phone, so cancel the plan temporarily. You can do that - I've done it many times when my daughter went either over the allowed amount of minutes or used it excessively in school.
No discussion needed! Just tell her up front what you're going to do, if she doesn't quit talking during class and then follow through with it.