The 43-year-old woman was pushing a four-year-old child in a shopping trolley while walking along Haig Crescent near the entrance of Bunbury Senior High School on Wednesday when the incident happened.
Police allege the woman brandished the knife and refused repeated requests to drop the weapon.
They said officers tasered her after becoming concerned for the child’s welfare.
Police said the child was not injured and arrangements have been made to place him in the care of family members.
The woman is undergoing a medical assessment at Bunbury Regional Hospital.
Students at the school were on their lunch break at the time of the incident and were asked to keep away from the front of the school.
Police are asking anyone who saw the woman in the area to contact Crimestoppers.