1) Define Observer in Module Configuration xml:
ModuleName/etc/config.xml
Sample code.:
<frontend>
<events>
<checkout_controller_onepage_save_shipping_method>
<observers>
<modulename_observer>
<type>singleton</type>
<class>modulename/observer</class>
<method>checkout_controller_onepage_save_shipping_method</method>
</modulename_observer>
</observers>
</checkout_controller_onepage_save_shipping_method>
</events>
</frontend>

2) Define Observer Inside Your Module:
ModuleName/Model/Observer.php
sample code.:
class NameSpace_ModuleName_Model_Observer
{
//Declare observer function
public function checkout_controller_onepage_save_shipping_method($observer)
{
//Set of code whatever you want to do
}
}