you can get anti scratch spray from pet shop to put on area or if you often see the cat scratching the carpet you can spray water at the cat to give it a gentle shock.
There is a product available from your vets called 'feliway' and it is available in a spray or diffuser. It emits pheremones, the cats happy hormone and can aid with scratching, spraying, inappropriate urination etc. The other answer is to buy your cat a scratching post as it is a very natural thing for your cat to do as they need to keep thier claws in check!
clip its claws, either take it to the vet to have it done or do it yourself if you feel you can. Just trim the very ends off, so the cat will still go to scratch, but wont actually pull the carpet up. Thats what I do with my cat anyway, stops her doing naughty things like pulling the stitching from the dining chairs