Add the parameter -console to your hl2 executable. The best method is to create a new shortcut to the hl2.exe and change its command line by adding the cheat/console parameter and then saving the shortcut. This way, you can play Half-life 2 with or without cheats (you can rename your shortcut to reflect this).
For some versions of Half-Life 2, you may need to add a longer parameter string -applaunch -dev -tconsole instead of the previously mentioned parameter.