A dog may chew up carpet for a variety of reasons. He may have too much energy and be looking for a way to work it off, he may be scared or anxious, or he may be playing and not realize it's wrong. Whatever his reason for acting badly, you want to stop him and redirect his attention before he destroys your carpets.
Crate-Train Your Dog
The quickest and easiest way to prevent your dog from chewing up the carpet is to crate-train him. Crate-training has other benefits as well -- it is much easier to house-train a dog who is crate-trained, and he will also stay out of trouble more easily if you can stick him in the crate while you aren't around. It's normal for your dog to whine or bark when initially introduced to the crate, but most dogs quickly come around to spending time there. You can ease the transition by having a special toy, perhaps a chew toy you can fill with treats, that he only gets when crated.
Use Taste Deterrents
If your dog has particular areas he likes to chew, such as around the door frame or the top of the stairs, you can put a quick stop to his bad behavior by using a commercial taste deterrent. These products are effective, readily available and easy to apply. Introduce your dog to the taste deterrent by wetting a cotton ball with the liquid and handing it to your dog. This way he will associate the odor with the taste, and when he smells it on the carpet he will automatically avoid it. Then spray the taste deterrent anywhere your dog has shown that he likes to chew. Taste deterrents are safe on most surfaces, but you may want to do a test spray behind the sofa or in some other unobtrusive area to make sure it doesn't fade or darken your carpet.
Increase His Exercise
Bad behavior, such as chewing on carpet, is often the result of your dog having too much energy. Don't assume that because he has access to a fenced yard or you take him on a walk every day that your dog is getting enough exercise. Take him on several brisk walks, or play games like fetch where he is forced to be active. Break the activity up into several short sessions instead of one long one.
Supervise Your Dog
When your dog is out, keep an eye on him. Don't leave him alone in the house while you go outside to get the mail, or leaving him sleeping in the living room while you take a shower. Once your dog has shown that he will chew on the carpet, it's up to you to keep an eye on him constantly until the issue is resolved. If you see him start to chew the carpet, a sharp "no" should be enough to let him know that this is unacceptable behavior. If you cannot watch him for a period of time, put him in the crate.
Visit the Vet
If you have worked diligently with your dog -- changing his lifestyle so he gets plenty of exercise and making sure he's supervised closely when loose in the house -- and he still wants to chew the carpet, a visit to the vet may be in order. Chewing on carpet, particularly when left alone, can be a sign of separation anxiety. If your vet suspects that your dog is suffering from separation anxiety, he can give you some tips for behavior modification as well as prescription medication that may ease his symptoms.