One of my fillies went through that when she was around that age.
I tried punishing her, I'd give her leg a smack with a stick
Then I started ignoring her and she stopped. I don't know if it was the lack of attention or if she just outgrew it.
She is an attention hog so I think the ignoring it did the best job.