djechlin's answer here, and an interesting Snopes article explain the psychological and social dimensions of the double meaning in the punchline. But the basic situation, the underlying meaning of "buying tickets to the Policeman's Ball", rests on some cultural presuppositions which these don't explain.
From the end of the 19th century forward it became common to raise funds for the families of fallen police officers by selling tickets to an annual "Policeman's Ball", an evening of dancing and drinking.
Such tickets were of course sold by officers to residents and businesses on their individual beats; and where the police were corrupt, this became an instrument of extortion: police offered "protection" not only from criminals but also from legal prosecution in return for the purchase of tickets—and many simply pocketed the proceeds, or shared the proceeds among cooperating officers.
Eventually, when automobiles became common, this shake-down system was extended to traffic offenses: motorists could buy their way out of court appearances (and out of the associated 'points' which might lead to having their drivers licenses suspended, and would certainly lead to higher premiums for their automobile insurance) by paying the officer who stopped them, the whole being spoken of euphemistically as the innocent and indeed praiseworthy act of "buying a ticket to the Policeman's Ball."
I had seen Dad get nabbed […] when the family drove me to Cleveland to report to the Indians during my high school vacation in the summer of 1936. A cop pulled us over in Indiana for breaking the speed limit.
He walked up to the car and asked Dad, “Would you like to buy a couple of tickets to the Policeman’s Ball?” Dad said sure. He knew what he was doing. He rather have them instead of a speeding ticket.
Dad bought the tickets and we headed to Cleveland, hundreds of miles from the site of the Policeman’s Ball.
—Now Pitching, Bob Feller
So when the lady says "I bet you're going to sell me tickets to the Highway Patrol Ball", she is in effect offering to bribe the patrolman.
The patrolman declines the bribe with the words "Highway patrolmen don't have balls"—meaning literally that the CHiPs don't sponsor such an annual fundraiser and figuratively that CHiPs are incorruptible.
Unfortunately (as the comments have told you) his words also bear a third sense: that highway patrolmen have no balls = "testicles". When he realizes what he has said the patrolman is so embarassed he simply closes his book (of 'tickets' or summons forms) and walks away.