The OPB704 IR Reflective Object Sensor is a focused reflect sensor that is used for the detection of changes in a surface. It will save you from ever falling off a cliff! Okay, maybe that's a bit dramatic. It will save your robot from ever falling down the stairs! That's better.
The OPB704 is a direct pin-for-pin replacement for the once popular, but now discontinued, QRB1114. One minor difference between the two is the length of leads. The OPB704 is shorter and it has a slightly lower forward current but otherwise the form factor and specs are the same if not better. The OPB704 is great for line detection with robots, it is a 3.8mm focused reflective Infrared Photo Detector. This sensor has a very narrow range of detection also making it ideal for wheel and RPM counters and non-contact surface sensing. One huge bonus to this sensor is that it has a slot in the that middle makes it easily mountable using #4 or M3 hardware.
If you want to detect the difference between white or black surfaces use an ADC (analog-to-digital convertor) pin on a microcontroller (such as an Arduino) or some other device that can utilize variable voltage levels. A black surface will give a voltage somewhere near the upper voltage (4~5V, when using a pull-up resistor), and white surfaces will give a voltage near ground (due to the phototransistor pulling the voltage down).