Usually capturing en passant is optional, but if a player does not
capture in passing immediately (right after the opponent moves a Pawn
two squares on its initial move), than he loses his option.
There is one instance when capturing en passant is compulsory.
If the only way to get out of check is by means of
such a capture, than
the capture must be made.
There is also one instance when capturing en passant is not allowed.
If capturing en passant would expose one's own King to attack (ie. to check), than the capture cannot be made.