Pc Lee Birch, 31, discharged his weapon into the bare chest of Daniel Dove in a cell at Melksham Police Station in Wiltshire.
Birch had arrested Mr Dove earlier that morning, on December 23 2012, outside Moo Moo nightclub in Trowbridge, Bristol Crown Court heard.
Mr Dove was charged with being drunk and disorderly and assaulting Pc Birch and a second officer, though the case against him was later dropped.
Birch was then charged with assault occasioning actual bodily harm and misconduct in a public office, which he denies.
Prosecuting, Robin Shellard told a jury Birch had used the "prohibited weapon" in a way that was not "necessary, lawful or proportionate".
"Mr Dove had been taken to a police station in Melksham, where he was placed in a cell and subjected to a strip search," Mr Shellard said.
"During the course of the strip search, when he was naked, a Taser was used against him by Pc Birch. It affected his bodily functions, made him collapse to the ground and curl up in a ball."
The court was told Mr Dove had been ejected from Moo Moo nightclub by doormen, who asked Birch and Pc David Read to attend at 2am.
Mr Dove allegedly punched Birch during his arrest and repeatedly kneed Pc Read in the groin - claims he strenuously denies.
The officers, of Wiltshire Police, then took Mr Dove to Melksham Police Station, where he was booked into the custody suite.
A strip search was authorised and began in a police cell, with Birch - who had taken the Taser from his holster and placed it behind his back - and two other officers attending.
"Mr Dove, then having taken his trousers off, takes his socks off and so it is that Mr Dove is in the cell with three officers, wearing nothing but a pair of boxers," Mr Shellard said.
"Mr Dove kneels down to take his boxers off, therefore being compliant. As he does so, Pc Birch moves forward to take the boxer shorts.
"As he does so, and as Mr Dove rises, Mr Dove flicks the boxer shorts at the police officers. They strike Pc Birch to the side of the face.
"Pc Birch produces the Taser and without any warning at all, he fires the Taser into the chest of the naked Mr Dove."
CCTV footage of the incident shows Birch ripping the boxers from Mr Dove and throwing them against the wall of the police cell.
The officer is then heard to shout: "You have assaulted me for the second time."
Mr Dove was left "prostrate on the ground" while Birch removed the prongs of the Taser from his chest.
Mr Shellard said the use of the Taser did not amount to "reasonable force", as Birch was accompanied by two officers, with others yards away in the custody suite.
"You ought to consider very carefully whether or not Mr Dove was acting in such a way that Pc Birch felt necessary to do what he did, and whether Pc Birch was, in fact, acting in lawful self defence," Mr Shellard told the jury.
Mr Dove, who was the first witness in the trial, told the jury he had been assaulted by Birch and Pc Read during his arrest and pushed down into a puddle on the street.
He also insisted Birch had overly tightened his handcuffs, causing him pain in his wrists.
But Mr Dove said he had co-operated fully with bouncers and police officers during his arrest and at the police station until the strip search.
"I was compliant the whole time I was in that cell, I wasn't violent at all," Mr Dove said.
"He [Birch] asked me to get naked, which I did. I did feel I had shown enough so they knew I had nothing on me.
"When he asked me to do it, I did feel quite embarrassed. I took my pants off and flicked them at him, towards his face. I was annoyed at him."
Mr Dove said he received no warning that Birch was armed with a Taser and that he was prepared to use it.
"As soon as I flicked my pants at him, he pulled his arm up from behind his back and shot me with a Taser," Mr Dove said.
"By the time I had seen it, I had no time to react or move. I couldn't hide anywhere, I was in a police station so couldn't run off.
"There was a lot of pain."
Colleagues of Birch told the jury Mr Dove had posed a threat to officers and been "aggressive" while in the custody suite.
The court heard a full strip search was necessary as Mr Dove had previously been found with cannabis in his jeans in 2009.
Pc James Rossiter said he stood behind Birch at the custody desk and in the police cell due to Mr Dove's behaviour.
Police procedure is for a suspect to remove the upper half of their clothing for inspection, then replacing it before the bottom half is removed to protect their dignity, the court was told.
"His reaction was rather than taking off the top half he just took everything off," Pc Rossiter said.
"He pulled his boxer shorts down, he assaulted Pc Birch by flicking him in the eye with his boxer shorts.
"It was a flick in the eye with the boxer shorts, then immediately Pc Birch pulled out his Taser and Tasered him."
In cross-examination, Stephen Mooney, representing Birch, asked: "He was demonstrating an obvious risk to those around him?"
Pc Rossiter replied: "Definitely, yes."
Another colleague, Pc Paul Brewster said Pc Birch had been "dead-pan and calm" after discharging the Taser.
"He appeared very calm and not het up at all," Pc Brewster said. "I heard him say 'you shouldn't have hit me in the face with your boxers'."