When Lister had given Rimmer a dose of Titan Mushrooms, Captain Hollister sentenced Lister to 2 weeks of Punishment Detail (PD). When Rimmer objected to such a lenient sentence, he lost his temper and stuck his pencil up the captain's nose. He then ripped up and ate a photograph of Hollister's wife. For this, Hollister gave Rimmer 8 weeks of PD.
Later, after Rimmer assaulted Hollister again, this time with green paint whilst the Captain was dressed for a fancy dress party, and Hollister extended Rimmer's PD to 8 months and then 8 years. This was presumably commuted when it was assumed that Rimmer was still hallucinating from the mushrooms.
The PD aboard Red Dwarf was to be made to paint the ship's exterior, a lengthy and meaningless task, given that painting would not work in a vacuum at below zero temperatures. The personnel had to wear space suits for this work. (Stasis Leak, Series II)
Red Dwarf had a brig, where prisoners could be held captive, as well as being held under house arrest in their quarters. More serious crimes could be punished with imprisonment in The Tank, and in extreme circumstances, The Hole. (Back in the Red, Series VIII)
As revealed in Series VIII, Punishment Detail could also include peeling mountains of potatoes in the cargo bays, cleaning out the sewers, and, in the case of prisoners of The Tank, playing a game of basketball against the guards.
Behind the scenes
In the opening title sequence for Series I and Series II, as well as the remastered episodes, Lister is shown painting the hull of Red Dwarf. This can be assumed to be a stint of PD, possibly that given to him in "Stasis Leak".