When your dog scratches at the door, he's telling you he's ready to come in or ready to go out -- getting him to stop means giving him another way to communicate with you. If you don't do that effectively, you could inadvertently backslide on housebreaking or replace one unwanted behavior with another.
Install a Pet Door
Put in a pet door and teach your dog how to use it to eliminate unwanted door scratching. A pet door should be big enough that your dog can get in and out without getting stuck. Be wary of the potential for wild animals coming in through the opening or inside pets or toddlers using the door themselves.
Install Doorbells or Jingle Bells
Install a doorbell within reach of your dog's nose or paw and train him to use it when he wants to go out or come in. Start by offering treats each time your pup successfully touches the bell and reinforce the behavior with praise when he uses it for its intended purposes. Jingle bells on a cord also can be used in the same manner.
Put up plexiglass or commercially produced "no scratch" door guards to protect your doors. This can be a temporary solution while you're training or a long-term solution if the scratching doesn't bother you, but door gouges do. No-scratch sprays and repellents also can be used on and around your doors, but that may inhibit your dog from going near the doors for any purpose.
Use a Barrier
Put up a temporary barrier by your door, such as a baby gate or an ottoman on the inside or a lawn chair on the outside. Give your pup a carpet square or other location to sit when he wants to come in or go out to train him away from the door. Once he's accustomed to the designated spot you can move the barriers.
Get on a Schedule
Anticipate when your dog wants to come in or go out and develop a schedule for opening and closing the door before he has to "ask." For example, if your pup usually needs to go out 10 minutes after eating, get into the habit of taking him to the door just before then. Likewise, if your dog usually wants to come in around sunset, open the door before he has a chance to start scratching.
Retrain Old Habits
Rehomed or rescue dogs may consider door-scratching an acceptable way to communicate going out or coming in. Break the habit by not responding to door scratching, but instead, praising and rewarding whatever other communication you replace it with, such as sitting by the door or barking to come in or go out. Be patient with these pups as they get accustomed to your house rules.
Check for Anxiety
Some dogs scratch because of anxiety. If you have a rough time breaking the habit on your own, take your dog for a checkup to rule out separation anxiety issues. You may be referred to a canine behavioral specialist to help you get to the root of your pup's problem.