<?php echo $this->getUrl("module/controller/method",  array("_secure"=>$_SERVER["HTTPS"]==="on"))?>

and for Skin :

<?php echo $this->getSkinUrl("images/search.gif" , array("_secure"=>$_SERVER["HTTPS"]==="on"))?>