The code is OK but there is a limit on how much current the Arduino can deliver per pin (40mA) and total board (200mA). So you won't be able to drive headphones directly as their impedance may be too low.
V = IR R = V/I = 5V/40mA = 125ohms So trying to drive any impedance less than 125 ohms would damage an arduino pin.
Ideally you would feed the arduino tone to a "line in" input on an amplifier, with the headphones connected to the amp.
As a minimum you need to add a resistor into a power transistor between the TONEpin and the headphones.