[not a teacher]
Normally "You're welcome" is in responce to appreciation (e.g. "thank you"). Here, he clearly doesn't appreciate not getting cookies (and probably storms off to his room upstairs), but she still thinks she's helping him. This is supposed to be funny. A non-humorous version is often used: "you'll thank me for this later".