Peanut butter and banana cannot cause a bacterial infection. But they can cause allergy.
A condition what is called as allergic pharyngitis which may result in sore throat.
If the allergy also involves your nose and Paranasal Sinuses it can produce secretions which may drip behind your throat. This may be the reason for frequently spitting out phelgm.
It is possible that allergy to certain allergens start later in life.
Next Steps
you can confirm your allergy status by doing a Serum IgE and Skin prick test. If positive can take antiallergic medications and immunotherapy if necessary.
Health Tips
Avoiding the allergens is the best method to control allergy. With medications allergy can be controlled. Not cured.