There is only one readily available study that looked at ball pits and the germs they may harbor.
This research looked at ball pits in children’s physical therapy centers and concluded that, even though they can harbor some germs, ball pits were safe for the majority of children. Only those with medical issues that affected their ability to fight infections, such as a compromised immune system, should avoid them (source).
While that accounts for serious illnesses, it’s certainly possible for children to get colds or flu from the use of public ball pits.
With home ball pits, like any other toy, you should wash any visible dirt or debris off the ball pit and the balls they contain.
In addition, a wipe down with hot soapy water once a month, when in use, should be enough to keep your ball pit clean. You should consider cleaning it more frequently if your child has friends over who also use the ball pit.