The beagle generally has a better sense of smell than the German shepherd. Beagles are scent hounds, specifically bred for tracking scents. They possess a large number of olfactory receptors and brains wired to process scents quickly and efficiently.
German shepherds are intelligent dogs with a good sense of smell, but they are not as specialized in scent tracking as beagles.