I think your puppy is having constipation. There are many reasons of this condition in dogs. These can be dehydration, lack of fiber in the diet, obstruction of GI tract, and some types of bacterial infections. Treatment depends upon underlying cause like antibiotics for bacterial infection and fibrous diet for constipation due to lack of fiber. So, it will be better to take your dog to vet for proper diagnosis and treatment.