The problem is most likely that you aren't accounting for the group delay of the filter. As an LTI system, your bandpass filter does two things to each frequency component present in its input signal:
- It multiplies the frequency component's magnitude by some value $A(\omega)$.
- It shifts the frequency component's phase by some phase angle $\theta(\omega)$.
Together, these two components make up the filter's frequency response. The second of these two effects is what yields the filter's group delay. That is, it takes some time for each component of the input signal to propagate through the filter. If you are looking to do some operation on the filter input and output that relies upon them being time-aligned, you have to account for this effect first.
With that said, doing such a thing with an IIR filter such as yours can be tricky. In general, IIR filters do not have linear phase. This means that your filter will delay some frequency components more than others. Again, if you're relying on time alignment of the filter input and output to do some operation, then this is going to work against you.
An alternative would be to use a symmetric FIR filter. These filters do have linear phase, so it will delay all frequency components by an equal number of samples (the delay $D$ is equal to half of the filter order, so if you have $N$ total coefficients, the delay is $\frac{N-1}{2}$ samples). If you did this, then you could accomplish what you want by doing the following:
- Pass your input signal $x[n]$ through the filter to get an output $y[n]$.
- Calculate the difference signal that you're looking for by adjusting your indexing according to the filter's group delay:
$$d[n] = x[n] - y\left[n + \frac{N-1}{2}\right]$$
Addendum: All of this begs the question of precisely what it is you're trying to do anyway. It seems like maybe you're trying to implement a bandstop filter by using a bandpass filter to isolate one frequency band and then subtract it from the original. It might make more sense to use a bandstop filter directly. For example, techniques exist to take a lowpass prototype filter and transform it to other types, like highpass, bandpass, or bandstop. This process might have been used to design your original bandpass filter anyway.