We've learned Kelsey Grammer is going into court this week ... asking a judge to impose a gag order on ex-wife Camille after her encounter with TMZ last week.
Our camera guy ran into Camille and her son last Tuesday -- and asked Camille which activities she enjoys doing with her kids. Camille instructed her son to answer the question and he replied, "Play."
Sources tell us Kelsey wasn't happy with the situation -- and wants the family judge to prohibit Camille from exposing their kids to media cameras in the future.
Sources connected with "Real Housewives of Beverly Hills" tell us ... Camille is indignant because just days later Kelsey paraded both of their children in front of a bank of cameras at Boa, a place ALWAYS buzzing with paparazzi.