The general function of a cylinder head for a diesel and a petrol is much the same, with a few noteworthy exceptions.
Diesel engines work at much higher compression ratios than their petrol equivalents, so the head needs to be physically more robust and strong.
Both diesels and petrols today have a method of injecting fuel into the cylinder (injectors) but a petrol engine injection system would normally inject pectrol into the cylinder head itself (direct injection), whereas in a diesel engine there is often a pre-cylinder ‘swirl chamber’ where the injected fuel is mixed with the intake air before the mix is then introduced to the cylinder (indirect injection). In older carburetted engines, there were no injectors and the fuel/air mixture was admitted to the engine using the inlet manifold having been mixed by the carburettor.
Petrol engines need spark plugs to effect the ignition and diesel engines don’t. They may have glowplug preheaters to raise the temperature of the combustion chamber for cold starting, but many diesels today don’t. Instead they have a fuel preheater or other device for warming the swirl chambers, rather than preheating the cylinders directly.
The explosion of diesel/air under compression ignition tends to be somewhat more violent than a petrol/air explosion ignited by a spark plug. This gives diesel engines their characteristic sound.