From the carpet used in bosses' offices when you were getting a telling off, or earlier, a table covering used in hearings. The subject being discussed was "on the carpet"
Correct in a way, it was from the Jockey Club, where the jockeys who had done something wrong in a race came before the stewards who sat at a table and there was a carpet in front of the table where they had to stand to give their side of the story and receive their punishment. The carpet still exists at the British Horseracing Museum in Newmarket.