The dog's reaction is called a scratch reflex. A dog has an area called a saddle area and when you scratch over it, this is his reaction. Interestingly, this area may vary from dog to dog.
Some are because its ticklish. Others are just because it is their feel good spot. Others can't control it, it just happens when you scratch a certain area.