I know we can have same psn account on ps3 and ps4 but after transfering to ps4 can I still play my ps3 games online?
You cannot play PS3 games on a PS4. There is probably an exception for digital purchases which have PS3 and PS4 variants, but most games do not have this.
You can still play those games online on your PS3. Having a PS4 does not invalidate the use of your PS3.
It's probably best to not think about it as "transferring" your account, and see it as simply signing into your PSN account on your PS4. You can still log into your PS3 with it, and even a Vita if you have one.
The question then comes down to "can I play my PS3 games on my PS4". The answer is no, as the PS4 is not backwards compatible.
But this doesn't mean you can't just simply sign in on your PS3 and play your games there.