Set Spanish Layout to an external keyboard
Usually, to make the OS match your keyboard, you go to System Preferences / Language &amp; Text / Input Sources and check the box for what you want, in your case you should try Spanish ISO or perhaps Spanish. 

Checking Show Input Menu in Menu Bar will display a Flag menu at the top right of the screen, under which you'll be able to select between your preferred keyboard layouts.

If neither Spanish ISO nor Spanish match your hardware, you can make a custom layout using Ukelele

Whatever layout you choose, it applies to both internal and external keyboards.