The choice of cephalosporin generation depends on the type of infection and the suspected or known causative organism. First-generation cephalosporins, like cephalexin, are effective against gram-positive bacteria. Later generations, such as third-generation cephalosporins like ceftriaxone, offer broader spectrum activity including gram-negative bacteria. Fourth and fifth-generation cephalosporins are reserved for more resistant organisms.