Q: How to do you decide that a particular key is a weak key?
That depends on the cipher (the algorithm itself). According to Wikipedia:
In cryptography, a weak key is a key, which, used with a specific cipher, makes the cipher behave in some undesirable way.
Q: I got some things like in case of WEP , the weak keys are those whose initialization vectors are in the form of ( B + 3,255,x).
WEP uses RC4 which, again according to Wikipedia:
Unlike a modern stream cipher (such as those in eSTREAM), RC4 does not take a separate nonce alongside the key. This means that if a single long-term key is to be used to securely encrypt multiple streams, the protocol must specify how to combine the nonce and the long-term key to generate the stream key for RC4.
So, unlike most ciphers, the weak keys include the IV. Unfortunately the key schedule of RC4 is weak, the IV of WEP too short and the construction of combining (concatenating) the key and IV too simplistic, leading to an attack.
Q:and does the condition for weak keys depend on the type of encryption function we use . ex - in wep , finally we are XORing the plaintext and the key sequence to get the ciphertext
Again, it depends on the cipher.
What you describe above is the general construction that a stream cipher uses to encrypt data. There are stream ciphers that have weak keys or are otherwise vulnerable. But there are certainly stream ciphers that do not have weak keys and are considered secure.
The XOR of the key stream with the plaintext is not the issue here.
Other (block) ciphers with weak keys are IDEA, Blowfish. DES is probably the best known cipher with weak keys though:
Since all the subkeys are identical, and DES is a Feistel network, the encryption function is self-inverting; that is, despite encrypting once giving a secure-looking cipher text, encrypting twice produces the original plaintext.
This means that if an attacker was to send back you the ciphertext as plaintext for you to encrypt (i.e. using you as an encryption oracle) that the attacker would retrieve the plaintext in the special case that weak keys were used.
Needless to say, modern ciphers try to avoid weak keys; each key should be as secure as any other key.