The joke is a pun on the word 'scratched'.  Fleas make dogs very itchy, so they will scratch themselves.  A racedog being 'scratched' means they are taken out of the race.
The race dogs got a bad case of the fleas - they had to be scratched .