How is public key cryptography used for digital signature? In public key cryptography, there are two different keys used for the encryption and decryption of data . I am wondering how it is used for digital signature
Aleksander's answer is very close, but there is one key difference between encrypting and signing a message.  When you create a digital signature, you are not encrypting the whole message.  The intent is only to validate that the message was indeed sent from you, not to prevent others from reading the message.  

To sign a message, first a cryptographic hash is created.  This is a calculated string that provides a unique "fingerprint" for your message, that anyone can reproduce on the other end to validate that the message received is the same as the message sent.  This hash, rather than the message itself is what is first encrypted by the recipient's public key, then your private key, then it's appended along with the message as the signature and sent to the recipient.  

The recipient must then use the sender's public key first, then their private key to decrypt the hash.  Once they have the received hash, the last step is to create their own hash of the message, and compare the two.  If the hashes match, the signature is valid, and everybody is happy!

Here's a great explanation: http://www.cs.utsa.edu/~bylander/cs1023/signature-encryption-example.html