TCP/IP doesn't really map cleanly onto the OSI model (which was designed top-down by a committee). If you want the closest map onto the OSI layers, the answer is probably 3.5: ICMP (which is what ping uses) is implemented directly on top of IP packets and doesn't use a transport layer (OSI layer 4) like TCP or UDP.