Herefordshire and Birmingham councils brought nine charges against Cadbury and has been successful in its prosecution on all counts.
Birmingham Crown Court was told that a leaking pipe at the Marlbrook factory caused the outbreak.
Cadbury pleaded guilty to all nine charges, including a failure to notify the authorities of positive tests for salmonella; the state of repair of the pipe and a roof vent; poor layout of the factory; poor provision of drainage facilities and neglecting to clean equipment.
Previously, Cadbury had always destroyed any chocolate which tested positive for the bacteria, but the firm changed its policy to save money, introducing an "allowable tolerance level" for salmonella in its products.
PA reported that the judge at Birmingham Crown Court said: "I regard this as a serious case of negligence. It therefore needs to be marked as such to emphasise the responsibility and care which the law requires of a company in Cadbury's position."
Solicitor Sallie Booth, of Irwin Mitchell, was representing 12 people affected by the contaminated chocolate.
She said in a statement: "Our clients are relieved that Cadbury have pleaded guilty to the charges brought against them, and in doing so accept their responsibility to the public."
"The £1 million fine sends a clear message that companies who have a great deal of responsibility for protecting public health cannot afford to ignore a potentially dangerous situation and cannot take a risk with the public's health. Public safety must come before profit."
The outbreak at the firm's plant in Herefordshire led to the recall of more than a million bars in the UK. More than 40 people became sick due to eating contaminated bars and three ended up in hospital.