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.
This could even be a back or spine trauma.
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.
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.
If your vet feels like it's appropriate, you can use aspirin at home to help control pain. You can get dosage information here:
Aspirin Info
If you're already doing that, there's not much else you can do at home. I really think he needs further diagnostic testing.
Let me know if you have more questions about this.
Not an active Expert