This is the Kodenshi SG-2BC. The manufacturer says: "The SG-2BC reflective sensor combines a GaAs IRED with a high-sensitivity phototransistor in a super-mini (4mm) ceramic package, reducing installation space."
Inside this 4mm diameter package, you get an IR LED and a phototransistor. The IR LED emits IR light and the phototransistor acts as a switch which opens and closes when it detects the reflected IR light.
Its effective range is only about 5mm at most, so it's finest application is detecting small objects passing very close. Typical applications would be watching how fast the floppy disc (remember them?) is spinning in a drive. I have used it as a rotational speed sensor on a spinning object. It can very easily detect a black spot on a white background.
Hooking it to a PIC couldn't be simpler. The LED connects to the power via a resistor - same as any other LED. With the transistor emitter to ground attach the collector to a PIC input with a high value (maybe 220K) pull-up resistor. (You could make use of the PIC's internal pull-ups.) Ideally, you would hook it to a comparator input so you could fine tune it but it will work reasonably well attached to a digital input.