ping is what layer?
ping in pure layer 2 LAN. You are correct the switch only knows/cares about the MAC. When you send a ping, it first generates a arp with a MAC(ffff.ffff.ffff) broadcast that goes to all ports asking for the MAC of a specific ip. Once the destination host receives the broadcast, is will see that it is a ARP for it's own IP, and using the MAC from the received packet, reply back to the original host, using known MAC's as src and dst.