How can i turn off charging when my phone connected to my computer?
Why would you want to do so? I don't think it's possible, at least on an unrooted phone. You can refer to the below discussions, they might come handy:


https://superuser.com/questions/429097/how-to-disable-usb-charging-of-external-devices-in-windows-7
https://stackoverflow.com/questions/15993635/how-to-stop-the-phone-from-charging-via-usb-programmatically
http://forum.xda-developers.com/showthread.php?t=787641