Students can log PIC time when they are flying solo once they have a solo flight endorsement. In this situation they are considered the PIC because they are the sole manipulator of the plane, and the person responsible for the flight.
Students can also log student pilot in command hours when they are flying with an instructor. This is because in those situations they are still the sole manipulator of the aircraft even if the pilot is legally responsible for the flight.