By "online" do you mean a browser-based game? If so, learn Flash.
A native application? C++ and Java seem to be popular choices for commercial games. For a hobby project without intense graphics, I'd consider Python. Look at Pygame: http://www.pygame.org/news.html
If you're talking about a multiplayer internet game, you're going to need a server. Will this game be in a persistent world (like MMOs) or will players launch individual games?
There's scads of languages to choose from on the server side. The basic scripting languages (Perl/Python/Ruby) might get you through if you're building a turn-based game. For a twitch game, you're probably looking at (again) C++ or Java.
If you want to build a persistent world for an MMO? That's going to be tough. Picking a programming language is not going to be the most pressing concern.