The Iraqi premier sacked three Baghdad security chiefs following a devastating bombing in the capital, his office said, hours after another attack to the north left at least 40 dead.