Ohm's law. 5V across 8 ohms is 5/8 = 625 mA. Average current if you're PWMing could hover around 300mA, more likely about 100mA. Absolute maximum, as in "never ever ever draw this much", per pin on most ATmegas is 40mA. Yes, you're overloading the everliving shit out of the chip.
Either connect it through a 200R resistor as Psi suggested, or use a small audio output transformer as was often done in the past when driving a low-impedance speaker from a low-current, relatively high-voltage (from the speaker's point of view) circuit.
Even better, use a cheap audio amplifier chip like LM386.
My guess is that the "Arduino Cookbook" is intending that you use a high-impedance speaker. My suggestion is to replace it with a dinner cookbook.