The phrase is usually attributed to Joseph P. Kennedy, father of the president, though football coach Knute Rockne also receives credit in some sources. It entered general circulation in the middle of the twentieth century as locker-room wisdom.
The joke sits in the pun. Going means both a situation and a departure, tough means both a condition and a person. The reversal turns a description of hardship into a description of character, which is why coaches have loved it for seventy years.
Among motivational chiasmus examples, this one is special because the meaning of each repeated word actually shifts between halves. Most chiasmus examples reverse the order of words; this one reverses their meaning too.
Source
en.wikipedia.org/wiki/When_the_Going_Gets_Tough,_the_Tough_Get_Going