We study the effect of absorption and amplification on transmission and filtering in one-dimensional dielectric photonic structures made of dangling side branches grafted periodically along an infinite monomode waveguide with defective branches. The loss and gain are introduced by adding an imaginary part ε″ to the dielectric constant. We show that for reasonable values of ε″, loss and gain affect essentially the transmission at the frequencies of localized modes associated with the defect branch introduced into the periodic structure. The amplitude and the phase of the transmission and reflection coefficients associated with defect modes are discussed as function of ε″ and the size of the structure. The properties of the defect modes in presence of loss and gain can be used as an on/off switching device in a demultiplexer made of the above photonic structures.