The correct way to write this word is online, without a hyphen or space. You may occasionally see online written with a hyphen, but that spelling is very unusual, and I do not recommend that you use it. Some writers and editors will consider it wrong.