I tried some iOS IRC clients, but when I put the app in the background, I am logged out.
Are there any iOS IRC clients that stay online when in background?
An app called Colloquy can run in the background for up to 10 minutes on iOS 5. No IRC app can run for more than 10 minutes in the background on iOS 5 due to how iOS is designed. The Colloquy web site has an FAQ that explains:
Can I run Mobile Colloquy in the background?
Yes, starting with Mobile Colloquy 1.3 & iOS 4.0 if you have an iPhone 4, 3GS, or a third-generation iPod touch (32GB and 64GB models from late 2009) you can, though it's important to understand how it works.
Due to the way multitasking is implemented in iOS, Mobile Colloquy can't stay connected constantly. When you press the Home button or switch applications, Mobile Colloquy asks iOS to allow it to continue to run to complete a task in the background, that task being to keep you connected for as long as possible. Any highlight word mentions, or private messages you receive will trigger a notification while Colloquy is running in the background.
Tasks can only last a maximum of 10 minutes, so 9 minutes after you've switched away from Colloquy it'll warn you that you'll be disconnected in a minute. To continue to stay connected, just tap Open on the alert. Switching back to Colloquy before 10 minutes have elapsed, then switching away again will reset the countdown.
For more details on how multitasking works in iOS 4.0, see this excellent blog post from Craig Hockenberry.