I believe it should be made when we add an item in cart, but I need to find code in Magento core where quote ID is generated and an object is made and similarly in the DB.
Yes, the quote is created as soon as you interact with the cart for the first time in your current session.
In the code, the object gets created in
Mage_Checkout_Model_Session::getQuote(), if no quote id is stored in the session yet:
$quote = Mage::getModel('sales/quote')->setStoreId(Mage::app()->getStore()->getId());
and saved to the database in
Most probably you are looking for
public function save() -> lines:
public function save().