Ah, there is no such virus. The truth behind what you've heard is the following.
Charlie Miller, a notorious iPhone hacker, claims to have discovered a vulnerability in the iPhone which allows him to execute any code on a remote iPhone by sending 512 SMS messages to it, only one of which appears on the phone. In his demonstration at the Black Hat Briefings, this particular message contained a little square - but it could be made to contain just about any character, including nothing visible.
Indeed, such a vulnerability is serious, especially given that Apple still hasn't patched it yet, and could, in theory, be used to construct an iPhone virus. However, the reality is that nobody but Charlie Miller and a few people at Apple know what exactly the vulnerability is and how to exploit it, and that no such virus actually exists. And even if it is created, it won't necessarily manifest itself by "a little square", so to "turn off your phone if you receive an SMS message containing a little square" is just an idiotic advice some moronic journalist has come up with when hearing about the whole thing. I won't be surprised if people start sending such (harmless) messages to each other as a prank.
Ignore it. It is not a practical threat to you and it is not a valid advice. As for "how long you have to keep the phone off" - well, the idea is that IF such a virus is created and IF you happen to receive it and IF it indeed manifests itself in such a visible way, then turning off the phone should prevent it from infecting other phones (i.e., sending itself to all the contacts in your phone book). It won't cure your (already infected) iPhone, of course. So, keep it turned off, until somebody comes up with a cure - which could be a long wait, given that even the disease doesn't exist in practice yet. Do you see now why it is an idiotic advice?