I was studying about CISCO routers and we learned that every router has a LOOPBACK interface. How and when are those interfaces used? We never used it though in our configurations.
...we learned that every router has a LOOPBACK interface.
That is not true. Cisco routers can be configured with loopback interfaces, but they don't have loopback interfaces until you create one.
The idea of a loopback interface is that it is a virtual interface which never goes down due to a physical line or network problem. Loopback interfaces can be used for testing, but they are often used for things like the OSPF router ID. By default, OSPF will select a router ID from the highest IP address on any interface. If you have any loopbacks configured, it will prefer loopback interfaces over real interfaces.
Loopbacks are often used as the source address for various services (NTP, TFTP, FTP, SSH, TACACS, domain lookup, etc.). These services would, by default, use the IP address of the interface by which they exit the router. This can cause problems if there are multiple interfaces exiting the router, and one goes down due to a line or external network problem. This could make the router seem like a different device to something working with a service, e.g. SSH or TACACS, and and spoil a connection. By using an interface which never goes down (loopback), it doesn't matter which physical interface is used. For instance, if you connect to a router that has several path by which you can reach it, and you connect to a physical interface, your connection may get dropped while you make changes to the router, but by connecting to the loopback, if you have any path into the router, your connection will remain up.
A loopback interface is a virtual (i.e. not physical) interface that never goes down, unless you disable it.
This way, if you configure an IP on this loopback interface and add it to your OSPF area (or any other routing protocol), it will always be reachable by whatever available/best path exists, provided that your router is not completely isolated.
I see several different cases where loopback IPs are better than "physical" IPs :
Administrative access to your device (Telnet, SSH, SNMP, HTTP API, etc.). With loopback IP you do not have to select an IP that may be down.
Sessions between devices (iBGP, targeted LDP, etc.). With loopback interface, if one path goes down the session remains up and just uses another path thanks to your internal routing protocol converging.
Administrative traffic from the device (Syslog, SNMP traps, sFlow/NetFlow, etc.). When you configure your device to use one of its loopback interface as a source to such services, you are able to filter/arrange such traffic by source IP on the receiving server without risk of it changing on the first topology movement.
In other words, loopback interfaces are a way to have a unique IP to identify or access the device, independent of topology changes.
As per Router IDs, it is usual to use the IP of the loopback interface for clarity (and most devices do this by default) but it is not mandatory at all.