To answer your question: yes, it is possible within Magento.
Now, there is no need to make a new attribute as suggested by another answer, as Magento has a 'cost' attribute already built-in.
So, once you have your attributes set for your products (so you're actually entering in COGS), you'll do something like this in your config.xml:
<events>
<sales_quote_save_after>
<observers>
<controller_action_after>
<class>yourmodule/observer</class>
<method>saveProfit</method>
</controller_action_after>
</observers>
</sales_quote_save_after>
</events>
And inside your Module/Model/Observer:
public function saveProfit($observer) {
// do stuff
}