The incident happened in Hill of Beath on Friday between 19:00 and 20:00.
The group of young children were walking home with the dog in Allan Park, when two male youths threw a lit firework, which narrowly missed them.
As an adult tried to get them to safety, another lit firework was thrown at the adult. Witnesses are being urged to come forward.
The youths are about 16 or 17 years old, white, of average height and of medium build.
One was wearing a jumper and grey jogging bottoms with elasticated ankles and the other was wearing stonewash jeans.
Sgt Caine McIntyre, of Police Scotland, said: "This is a dangerous and reckless act which could have caused serious injury to the parties involved."
Two youths who threw fireworks at a group of children out walking a dog in Fife are being sought by police.