Driving a tiny speaker via pwm, amplified with a BJT - in reverse?
Okay, we've established it's an electromagnetic type transducer.
The resistor appears to be 270 ohms, not 2.7K.
You may be excessively overdriving it with the transistor working properly. An electromagnet transducer in that resistance range is probably expecting about 1.5V. It also should have a diode across it because of the inductance (one I happen to have measures 40.8\$\Omega\$ and 0.7mH), so try about 50 ohms in series and a 1N4148 across the pair.
For reference, here is a similar part.