Because, the laws do not differentiate muggles as the ones who know about magic and those who don’t.
In Harry Potter and the Chamber of Secrets, when Dobby performs the levitating spell ok the cake, Harry receives a letter from the ministry saying:
We would also ask you to remember that any magical activity which risks notice by members of the non-magical community (Muggles) is a serious offence, under section 13 of the International Confederation of Warlocks’ Statute of Secrecy.
Enjoy your holidays!
This, is not much clear on the matter. However, per Pottermore:
The main law of magic in the wizarding world is the obvious one: don’t perform it in front of the Muggles! It’s sad that things came to this, but the International Statute of Secrecy is steeped in a chequered history - with events such as the Salem Witch Trials and various other hostile acts leading to this golden rule being decreed in 1692.
It doesn’t specifically says that it’s ok if the muggle knew about the magical community.
Ministry plotting against Harry
After Harry’s claim that the Dark Lord had returned at the end of Harry Potter and the Goblet of Fire, the ministry (Umbridge, specifically) may have decided to ruin Harry’s reputation as his claim about the Dark Lord made the ministry look weak to the wizarding community.