Usually, I refer to the city's alignment when I decide what kind of punishment would be suitable. I was wondering if there are any official criminal codes, covering how specific wrongdoing should be punished in the Flanaess. I am especially interested in Greyhawk and countries around the Kron Hills.
Yes, various cities and states have their own formal criminal codes.
While there is no one standardized legal system across the Flanaess, the Free City of Greyhawk in particular has a formally written criminal code with specific punishments, as described in the City of Greyhawk boxed set.
While other cities or kingdoms may have the elaborate formal systems similar to or inspired by the City of Greyhawk—including much of the Flanaess which was once part of the Great Kingdom, whose laws of Schandor established a fair system of formal judges and courts—this system of justice is not universal across the Flanaess.
The legal system of many lands are simply not detailed in any canon work, and left to the DM's invention. This is very much in keeping with Gary Gygax's original vision for the setting, in which he states that the World of Greyhawk truly belongs to each DM to fill in the details as they see fit.
Free City of Greyhawk
In the Free City of Greyhawk, serious crimes are tried by one of eight city judges. Serious crimes are officially defined and include such things as arson, grievious assault (any assault which results in a broken bone, major facial injury or worse), blackmail, bribery of a city official, impersonation of a city official, genocide, treason, importation of evil artifacts, magical interference with the integrity of a person (such as charm or polymorph), tomb robbing, and possessing an unlicensed monster.
The possible sentences for each crime are officially laid out, and include death, exile, mutilation, hard labor, and fines. Convictions for major crimes can be appealed. The courts may not use magic to determine guilt, due to old laws and tradition.
Minor crimes include blasphemy against a priest, disturbing the peace, dangerous nagivation within the harmor, slavery, tax evasion, and using magic in a public place without due cause. The minor crimes have smaller punishments which vary greatly depending on the mood of the judge.
Notably, the book intentionally allows broad choice for the DM. While the most serious crimes are punishable exclusively by death, the exact sentence and choice for most crimes is up to the individual judge, and therefore up to the DM. Fines are not strictly defined, so it's really up to the DM whether to levy 50 gp or 5,000 gp as a punishment as the campaign warrants.
Notably, there's a lack of ordinary "imprisonment" as you would see in the real-world modern-day justice system. There's imprisonment with labor, where it might be considered that the criminal repays their debt to society through their work, but there's no system where an individual simply lives apart from society for lengthy periods of times at the expense of the state.
The former Great Kingdom had a formal system of judges who would travel the land along the great dirawein roadways dispensing regional judgements. One can infer that criminals were held in local jails to await the arrival of a judge. The priesthood of Pholtus served as judges in the capital. The Great Kingdom had a formal set of laws.
The Judges of the Sessions, as they were known, tried major crimes such as murder, theft, and the theft of property worth over 500 gp. Sentencing guidelines were somewhat standardized throughout the kingdom, and punishments were not excessive. They generally required that the criminal made fair restitution to the victim or the victim's family, whether through fines or forced labor. Local rulers appointed their own magistrates who ultimately decided their own regional laws and punishments within these guidelines.
Most notably, this system of law was established by Schandor in the early days of the Great Kingdom, which at one point rose to cover much of the Flanaess, to the extent that the modern day Common language derived from the Great Kingdom Oeridian language and its Common Year calendar became de facto standards among humans. This suggests that a formal legal system is a well-known concept in much of the Flanaess, and that many other nations at least in the most civilized lands have a similar system, or at least had one in the past. We might reasonably infer that the City of Greyhawk's legal system was influenced by the system established by Schandor, since the lands of Greyhawk did originally fall within the farthest reaches of the Great Kingdom at its height some centuries ago when the Free City was little more than an unimportant mining town.
Following the collapse of the Great Kingdom, this was replaced with a "might is right" policy which allowed local rulers to simply dispense justice as they see fit, often harshly and with inequal status given to the rich and powerful. Summary execution for perceived treason was common, with the settlement of Bluelode dispensing immediate execution as punishment for theft. This harsh system may still hold in the North Kingdom, still dominated by the church of Hextor.
Asperd Isle is ruled by the military Naval Phalanx, who dispense summary justice, including imprisonment and, presumably, execution for serious crimes. Its prison is dilapitated and disease is rife.
The Mouqollad Consortium has authority to settle disputes between nomadic Baklunish merchants.
Clerics of Al'Akbar, Allitur, Heironeous, Mayaheine and Pholtus often serve as judges, suggesting that the formal role of a judge is somewhat widespread.