From a layman's perspective what does it mean getting packets in and out of CPU?
A switches primary function is to efficiently switch frames as fast as possible. In order to do that, they use FIBs to sustain a high, low latency throughput rate. This is generally achieved by using CAM that operates in an ASIC (i.e. hardware).
Does that mean all packets that ingress/egress a switch typically don't go through the CPU?
Most of the time, this is accurate. But not always.
There are packets that don’t just pass through a switch, but are destined for the switch. This requires processing. SSH, SVI’s, STP, etc. all require some sort of CPU processing by the switch. Whenever a switch is tasked with scrutinizing a packet further, it’s bound to take up resources that could be used elsewhere.
what are some of the cases where you need to send the packet to a CPU?
This is highly dependent on your platform. But if it’s destined for your switch, then it’s going to require CPU processing. Routing protocols (EIGRP/OSPF), spanning-tree protocols(RSTP/MSTP), management protocols(SNMP), remote access protocols(SSH) and discovery protocols(CDP/LLDP) are a few that initially come to mind.