How does a labyrinth seal work when the engine isn't rotating?
An example of oil labyrinth seal use

I'm taking the bearing sumps example. There are several bearings to maintain the engine rotors and shafts centered within the core and the stators. Some may use labyrinth seals.


Source.

Pressurized cavity during operation

In a bearing sump with classic dry design, oil is provided directly to the bearing, and labyrinths seals maintain oil within a first cavity (the sump). There is another cavity around the first where compressed air is injected. Air is tapped for internal use from a compressor stage (bleed air).


Source.

This way if oil escapes the first labyrinth of the oil seal, it is contained by the pressure of air coming from the outer cavity on the other side of the seal.

Actually air, which is provided at a higher pressure than oil, will enter the inner oil cavity and mix with oil to form a mist. This is why scavenged oil must then be filtered to separate air when returning to the oil tank (oil must also be cooled has the bearing generates a significant amount of heat).

Oil is directed to the bearing using jet nozzles, the sump is not completely filled. Someone more knowledgeable may explain why, perhaps an oil boundary layer would appear and create unnecessary friction:


Source: Gas Turbines, A Handbook of Air, Land and Sea Applications

In today's engines, oil is circulated using pumps. There are two pumps: One to supply with oil and one to scavenge oil. To ensure oil doesn't accumulate into the sump, the scavenge pump has a higher capacity. Both pumps are driven by the rotation of the engine. 

Non operating engine

The pumps are mechanical and driven by one of the engine shafts.

When the engine is not operating, the pumps stop, oil is not supplied any more and it leaves the sump by the scavenge pipe. Bleed air isn't necessary any longer.

When the engine is started, the pumps also start. Oil is therefore injected again into the sump.

The bearing can sustain lack of lubrication for a short time, and there can be an emergency system if oil supply from the tank is interrupted.

Residual leakage

As there will be some limited leakage anyway, oil is extracted by the cavity drain and disposed overboard (or returned to the oil tank).