It's a nervous habit and she may not even be aware that she's doing it. I did the same thing when I was roughly the same age. My mom made such a big deal out of it that I took it underground, so to speak, and only did it when I was alone. To this day I can't explain the compulsion, but eventually I stopped doing it. I didn't consciously make the decision to stop; I just did.
Your daughter will likely outgrow the habit as well, but to help her along explain to her why it's not a good idea and tell her that whenever you see her doing it you're going to remind her to stop. When you catch her doing it, gently give her a one-word reminder. Whenever I caught my daugher biting her nails when she was 6 I'd quietly say, "Fingers". It brought attention to her habit and she quickly took her fingers out of her mouth. It took a lot of reminders, but she did stop.