Basically any change to the System Configuration. When you create a code block, that creates a new heap-item in the System Configuration, hence requires a transition to Program mode. Same with a PID instruction - it automagically creates a new PID structure heap item.
The System Configuration changes the structure of everything ladder logic does, possibly changing the actual low level ladder logic opcodes written to the PLC. Hence, the Program ladder opcodes must be re-generated with the new System Configuration, and the System Configuration itself must be updated in Program mode.