The synthesis or release of an antibacterial peptide during an immune response, resulting in an increase in intracellular or extracellular levels.