Get Pet Questions Answered by Pet Experts
You first need to determine the cause of the pain. The most common injury in some dogs is probably a torn cranial cruciate. This is comparable to the ACL ligament in people. If this is the case, there are surgeries that can repair it and the vet will offer steroids and anti-inflammatories to help with pain.
Another cause might be a luxating patella. In layman's terms this means wiggly kneecaps. If a dog has this condition, the knee will slip into and out of place. The dog might straighten the leg to flex it back in place.
You should also look closely around the foot and between the toes to look for foreign objects. Ingrown toenails if they have grown too long can be pretty painful.
I hope this helps!
If this does not resolve soon, you should see your vet for a diagnosis and to discuss your treatment options. Unfortunately, you can't tell from the outside what the source of the pain may be.
Let me know if you have more questions about this.