In the limit where $m_2 \ll m_1$, only the mass of the heavy body matters (along with the semi-major axis of the orbit, of course).
Where that limit does not apply, varying the mass of either body changes the reduced mass:
$$ \mu = \frac{m_1 m_2}{m_1 + m_2} .$$
Since the system acts as if a negligibly massive object was moving in the field of one having the reduced mass, this does alter the period.
Notice that in the limit above $\mu \to m_2$ and we recover the expected behavior.
Marion and Thorton give the full expression for the period $\tau$ in the form
$$ \tau^2 = \frac{4 \pi}{G} \frac{a^3}{m_1 + m_2} $$
where $a$ is the length of the semi-major axis of the orbit and $G$ is the gravitational constant. It should be obvious that in the limit of a heavy primary this reduces to $\tau^2 = \frac{4 \pi}{G} \frac{a^3}{m_1}$.
Side comment: The rule you recall is the one Kepler found for planets in our Solar System. In this case the mass of the sun dominates in every case. Jupiter is about 0.001 solar masses, so the largest correction in at the tenth of a percent level. Observable, but not at all large.