At the end of the book, after Dallas and Johnny have been killed, Ponyboy is still recovering from his concussion. The trial happens during this time, and the judge asks Ponyboy some rudimentary questions, and acquits him of any wrongdoing. Most likely because of the trial, his concussion, and the deaths of his friends, Ponyboy's grades start falling off, and the other Greasers notice some personality changes in Ponyboy. He is far more detached than normal and possibly suffering from bouts of depression (medically speaking, those are all signs and symptoms of concussion trauma and serve as indicators that the brain is not fully healed; it can last for months).
It's during this time that Bob Sheldon gets in Ponyboy's face. Pony is sick of it, so he cracks off the top of his bottle and threatens to cut Bob up unless he leaves. Bob leaves, and the other greasers are concerned that Ponyboy is turning cold, dark, ruthless, and hard. Two-Bit begins to tell Pony "listen, don't get tough. You're not like the rest of us and don't try to be . . ." They don't want to see Pony's character and demeanor change. They like him the way that he is, so when Pony begins picking up the glass because he doesn't want somebody to get a flat tire, they are relieved to see that Pony's true character is still there. Two-Bit's "You little sonofagun" is a relieved term of endearment toward Ponyboy. He realizes that Pony was putting on a false face to get rid of Bob, and Two-Bit is sort of teasing Ponyboy about fooling Two-Bit so completely.
When Ponyboy starts picking up the glass pieces, Two-Bit realises why he is doing so. Ponyboy does not want anyone to get hurt by the glass. He is relieved that Pony's nature is different from that of the rest of the Greasers, and so is relieved that Pony is not acting tough. He then calls him "Little Sonofagun".