What you do with an object after you have obtained an interface pointer depends entirely on the object itself and is really what most of the chapters in the book are about. You must, in any case, be absolutely sure to call Release through that interface pointer when you have finished with the object. Otherwise, you doom the object to live in memory for all eternity—or until the universe collapses (power off or the jolly three-finger reset).
Releasing the object is not the only consideration when in-process modules (servers and handlers) are involved. Local servers, remember, will terminate themselves when they're no longer in use. DLLs, however, must wait for COM to call DllCanUnloadNow from within the CoFreeUnusedLibraries function. As a client, you are responsible for periodically calling this COM function because COM does not make the call itself. A good time to call the function is immediately after releasing what you consider to be the last interface pointer to an object. Another good choice is to call the function every minute or two during any idle-time processing your application might do.
Remember that a reference count on a class factory does not guarantee that the server will stay in memory and that you can use the class factory later. If you want to hold the class factory's pointer across function calls (especially across iterations through your message loop if you have one), you must call IClassFactory::LockServer(TRUE) when you save the pointer and IClassFactory::LockServer(FALSE) before calling its Release.
One additional function that a client might find useful in managing servers is CoFreeAllLibraries, a much more brutal version of CoFreeUnusedLibraries that forcibly dumps all DLLs out of memory without regard to their object counts or lock counts. This isn't a good function to call in the course of normal processing, but it exists so that a client can clean up its address space during an abnormal termination. CoFreeAllLibraries is called from within CoUninitialize, so clients generally don't need to call this function directly during shutdown.