Optocoupler is as shown in fig. it consist of LED as an light source and phototransistor act as light detector.
When input pulse is applied LED turns ON.Light emitted by LED focused on CB junction of phototransistor .
In response to this light photocurrent starts flowing which acts as base current of phototransistor.
Collector current starts flowing.As input pulse reduces to zero LED turns OFF collector current becomes zero.