Is it possible to trace my IP address when I am chatting with others (with gtalk or Facebook)? If so, how could someone do that?
Set up a web server and send them a link to something on it. Once they click the link, their IP address will be logged in your web server's access logs.
You could also host an image on said web server and trick a user into loading it through a third party's website. Some social networking sites allow you to upload snippets of HTML including image tags.
Note, when I say "their IP address" I am referring to whatever the address is after any NAT and proxying.
It depends on the protocol. If its ICQ/AIM style instant messaging, communication is done through a direct TCP connection to the other server . Hence, you can turn on wireshark or another packet sniffer on your local machine and observe the IP address of everyone you are chatting with easily in ICQ/AIM.
If its Gchat style instant messaging (based on Jabber/XMPP protocol), when you send an instant message to someone the message first gets sent to one of google's servers, and then that server sends the message to the other computer  . Their IP address does not seem to be recorded in any way in the logs google provides to the user. Thus, unless you work at google and have access to their internal logs you can't observe their IP address from chatting with them.
Granted as chao-mu mentioned, you can try asking them to directly connect to a server you control or have access to the logs (and then you can find their IP address). Also, that the IP address could be through a proxy (e.g., they sit at computer 18.104.22.168 but route all outgoing traffic through a proxy server 22.214.171.124) or could be be NAT, e.g., their cable modem has IP 126.96.36.199 is connected to a router that assigned their machine 192.168.1.100 (and the router can assign several other IP addresses 192.168.1.101 to other computers), but will look to the outside world as 188.8.131.52.