Lameness can come on suddenly after play, a fall or another injury, but it can also develop gradually with osteoarthritis or other joint disease, for example. Do check whether something is stuck in the paw, whether a claw is damaged and whether you can see swelling. Avoid bending and twisting a painful leg, however, to try to make a diagnosis at home.
How your dog moves, when the lameness shows and whether it improves after rest give important information. The vet usually examines the whole leg and compares both sides. X-rays or other imaging may be needed, but not every cause of lameness shows on an ordinary X-ray.
Seek care the same day if your dog will not put weight on the leg, is clearly in pain, has marked swelling or has been through a major trauma. A mild lameness that does not quickly go away, or that keeps coming back, should also be examined so that a long-term painful condition is not missed.