Penicillin is a bacteria so it means it causes the production of antibodies which then boost the immune system.
It is like vaccination; small doses of the inactive form of the infection is injected into the body in order for the body to create antibodies resistant to such infection(thereby boosting the immune system).