A network can be created by connecting more than one computer together. When one machine wants to communicate with another one in the same network or in another network (if the networks are connected.), IP address and Port number plays a major role. Let’s get into IP address and Port number.
IP Address is 32 bit binary used for identifying a machine in the network. At any point of time no two machines of a same network can have same IP address. IP address are mostly referred with dotted decimal notation. This notation consist of four decimal numbers each vary from 0 to 255 and separated by decimal dot (.). So, for example IP address looks like 148.45.56.23. There are four classes in IP address and the explanation of those classes are beyond the scope of this post. In one line, IP address is used to identify the machine in a network. Most of the people knew what is IP address and why it is needed. So let’s move to the Port number.
Port Number is an integer number used to identify a communication among many, going on in a machine. Mostly port numbers are associated with application which involves in a communication. For example, a machine can communicate with the FTP server while it is being accessed by another machine for some reasons. So without Port number conflict become obvious.

From the above figure, it is very clear that a machine can participate in more than one communicate simultaneously and to avoid conflict the Port numbers are used. Each communication will use different Port numbers. More clearly it is not communication rather application which is involved in communication. For example, Computer A wants to access the internet it needs a browser and the browser will be assigned with some random port number and the web server will be assigned with known port number 80. So the Computer A uses random/dynamic port and the Web server uses know port 80 for its communication. During this Computer A can access the FTP server using another unused port and the FTP server use the known port 20 and 21.
Thus, IP addresses are used for identifying a machine in network and Port numbers are used for identifying an application which is involved in a communication.
For more details about the applications and Ports association, see http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers.