Hoffenheim scored three second-half goals to beat their Baden-Württemberg rivals and consolidate third place in the Bundesliga standings.