I don't know anything about TeamViewer, but it might help narrow down the problem if you "took it out of the equation" and checked to see if Wake On Lan works for the built-in OS X sharing services.
You can test this by going to System Preferences-->Sharing and choosing one of the services, like Screen Sharing and/or File Sharing.
Also in System Preferences-->Energy Saver, ensure you have "Wake for network Access" (or equivalent--wording is slightly different on different machines) checked.
Put that machine (the one sharing the service) to sleep. Go to another Mac and open Finder. The sharing Mac should be listed under "Shared" if you have checked the items under Shared in Finder-->Preferences-->Sidebar. Click on the sharing Mac's name. The sleeping Mac should wake up, and the window should show the Mac's shared folders and a Share Screen button. (I don't remember if you have to click on Connect As... the first time, or not...)
(At least, that's how it used to work for me. Wake on Lan/sharing used to work wonderfully for me, but lately it has stopped working. I think it might have stopped working when I upgraded to Mountain Lion.)