We have to distinguish between civilian and military views on crime or other offense here. Starfleet personnel apparently face punishment for wrongdoing, ranging from demotion to incarceration; we never hear of civilians facing punishment for anything. Instead, the stock response to a civilian committing a crime or other offense is therapy.
This therapy involves forcing the patient to stay in therapy, but that's not punishment by jailing - the "sentence" is the same whether you smuggle medicine to rebels or try to exterminate a species and possibly start galaxy-wide war, namely, six months of said therapy.
TOS indeed features two facilities providing therapy, one "regular" but perversely run in "Dagger of the Mind", one reserved for incurables and taken over by the inmates in "Whom Gods Destroy". But that's not all - TOS is very consistent about punishment being a thing of the past, and therapy being the answer to everything. When Lenore Karidian is caught murdering people left and right, she faces therapy. When Mudd's criminal record is studied, it includes charges on smuggling (suspended) and transport of stolen goods as well as purchase of vessel with counterfeit currency (sentence: psychiatric treatment).
Starfleet has a death penalty, apparently not with regard to crime but as deterrent against behavior that might jeopardize the safety of the human race (and a few others on the side). Initially, it's for violating General Order 7, which apparently deals with planetary quarantine and thus affects attempts to go to Talos IV. But Kirk goes there anyway, and the issue becomes moot; soon afterwards, the death penalty shifts to General Order 4, the nature of which is unknown (all we learn is that it doesn't relate to mutiny aboard a starship in any way).
TNG keeps up the good effort, as everybody from Kasidy Yates to Garak to Tom Paris gets "therapy", and comes out reformed. Very nicely reformed at that, as they are only cured of the single type of crime they committed, and are not diminished in any other way. But Quark gets a fine, which is a punishment. Then again, Quark isn't Federation. Then again, neither is Garak... (Perhaps for the Ferengi, a fine counts as reforming psychiatric treatment?)
TNG also adds an interesting tidbit when in "Justice" Picard says that criminal tendencies are screened against (as mentioned above). We don't know how that happens - are kids who fail a psych test quietly put to death or what? But Picard doesn't claim that this would be particularly effective in negating crime, nor that the UFP in general would be crime-free. It's just a thing the Feds do that helps them survive without draconian laws and death squads of the Edo sort.
Timo Saloniemi