It is likely this behavior began as a means of stress/tension reduction and developed into a habit pattern. You can stop it via a combination of cognitive-behavioral therapy and perhaps medication. This Forum addresses child issues, but you should post your question in the Mental Health Forum for additional guidance.
Hi, try putting nail biting varnish on, or piri piri. My kids sometimes do the same, and I am so worried about all the germs that they may be transmitting to their system, that I put the varnish on and it stops them whilst its on.