In a nutshell, the network stack of which TCP is part of is made up of many layers. This is called the OSI network model.
http://osilayers.org/
The control of what data goes to where I believe is at layer 4.
Which application sees what data in TCP/IP is based on the port number which I hope you are familiar with from reading about TCP/IP. But if not, every connection has a port which is a bit like a set of post office mail boxes. Those mailboxes are located at an address, and each one is numbered. Similarly, the computer can have an IP address (like a physical address), and the mailbox numbers correspond to the port numbers.
Software at layer 4 will put the data packets into the correct places like a mail man puts the mail into the correct boxes.
Interpretation of the packets happens at different layers of the OSI model.
For example, TCP is actually a protocol built on top of IP. IP is implemented at the network layer (4). While TCP is at the (higher level) session layer 5. TCP is actually built on top of IP. The same is true for UDP. UDP is built on top of IP.
At the very top of the OSI model is the application layer. This is where applications like FTP etc will reside.
That's a very quick summary but I hope it helps.