There are many points in the novel in which Pip reflects on his bad behavior toward Joe. In Chapter 52, the injured Pip, who is unable to cut his own dinner, has a conversation with the landlord at the inn while the landlord cuts his food for him. It is this conversation that causes Pip to feel worse about his behavior than ever before.
The landlord, not recognizing Pip as the same child he used to know (and thus not knowing to whom he was speaking), proceeds to explain that Mr. Pumblechook "done everything" for Pip, and that Pip "gives the cold shoulder to the man that made him" each time he returns to the village.
As Pumblechook always took credit for being Pip's first benefactor, Pip is angered by this conversation. Further, he thinks about all Joe has done for him, and acknowledges that Joe has never taken any credit for anything he's done for Pip:
I have never been struck at so keenly for my thanklessness to Joe, as through the brazen impostor Pumblechook. The falser he, the truer Joe; the meaner he, the nobler Joe.
In this chapter, Pip is on his way out to the marshes to meet whoever it is that has sent him the anonymous letter. On the way, he stops at an inn. The landlord of the inn tells him his own (Pip's own) story, not knowing that Pip is Pip. This is why Pip regrets the way he has treated Joe.
The reason this causes him to regret his actions is that the landlord tells him that Pumblechook is the one who was responsible for Pip's good fortune. Pumblechook has apparently been going around talking about how he "made" Pip. When Pip hears this, he thinks about how much he owes Joe and about how Joe does not go around talking about Pip.
So Pip feels bad because he contrasts Joe's good actions with Pumblechook's bad actions and he realizes that he has not treated Joe as well as he should have.