The referee must stop the game as he sees the foreign object in the pitch which will affect the flow of the match. For this case, if the referee saw the balloon only after the ball was shot goalward and scored, he had to allow it. In this case, it was surely not the case.
The referee surely had seen the balloon much earlier but did not stop the game for it. Until the goal was scored he realised the balloon affected the flow, but he allowed the goal to cover his own mistake.