The 'onCollapse' is one of panel events. It need to be applied on the panel component. Call 'getPanel' method of accordion to get a panel and attach the 'onCollapse' event to it.
var p = $('#aa').accordion('getPanel',1); // get the second panel
var opts = p.panel('options');
var onCollapse = opts.onCollapse;
opts.onCollapse = function(){
$(this).panel('setTitle', 'Click to expand');
onCollapse.call(this);
}