I am using Arduino Digital Pins to turn on and off a relay. Now I am using the 5V and GND from the board and supplying this to the relay. This power is turned on/off using a NPN 2n2222. This transistor in turn switches on/off the relay. Now I can make this happen by supplying the power from 3V supply on board. Now I want this to happen using the digital pins. This works, but only on pin13 and not on others. What can be the reason?
If I remember correctly, header pin 13 on Arduinos is usually connected to an on-board LED. This may cause it to behave differently under some circumstances.
The best way to understand this is to examine the circuit diagram of your specific Arduino model (or Arduino-compatible model)
Duemilanove Pin 13 LED Uno Rev 3 Pin 13 LED (marked "L")
On recent official Arduino products (Uno, Leonardo ...) it looks like the pin 13 LED is isolated by an op-amp buffer so the LED shouldn't affect use of pin 13 for other purposes? I don't know if this is the case for other companies' "compatible" products.
Notice that many (all?) of the pins have multiple alternate functions, if you have enabled those alternate functions you cannot safely use the same pins for controlling LEDs etc.
P.S. For questions like this I think you should post a circuit diagram for your added circuit (and maybe a photo too - but not instead of the circuit diagram). It is also a good idea to cut your code (sketch) down to the smallest and simplest that reliably reproduces the problem and include that code in your question.