During every IEC-cycle, the FOR loop is going to be started again. For this reason, the FOR loop must be enclosed in an IF statement that we set to FALSE after the first time through the loop. For example:
PROGRAM PLC_PRG
VAR
Counter: INT;
Erg: INT;
Var1: INT;
OUTFOR: INT;
END_VAR
IF OUTFOR <> 1 THEN
FOR Counter:=1 TO 5 BY 1 DO
Var1:=Var1+2;
IF Counter = 5 THEN
OUTFOR := 1;
END_IF
END_FOR;
Erg:=Var1;
END_IF