It is not generally illegal. It is possible to get a court order in the context of or during a divorce case barring your child from being around your girlfriend, if there was some evidence or showing that she is a threat or bad influence (e.g. a drug user; psychological/emotional issues; history of abusing children; etc.), but until and unless your spouse applies for such an order and gets it, your child may be near your girlfriend.