1887, sporting slang, origin obscure, probably from somebody's long-forgotten lame racehorse. Charley horse seems to have been a name for a horse or a type of horse (perhaps especially a lame one) around that time.
charley horse char·ley horse (chär'lē hôrs')
Localized pain or stiffness in a muscle following excessive muscular exertion or the contusion of a muscle.
A stiff and painful inflammation of a muscle, esp of the large thigh muscle (1887+)