The following sample code may be useful if you want to know whether a sublayout is used anywhere.

 1: Sitecore.Context.SetActiveSite("shell");
 2: Database masterdb = Sitecore.Context.ContentDatabase;
 3:  
 4: // item for which we check sublayout reference
 5: Item item = masterdb.Items["/sitecore/content/home/test"];
 6:  
 7: // get Renderings field of the item
 8: string rend = item.Fields["__renderings"].Value;
 9: LayoutDefinition layout = LayoutDefinition.Parse(rend);
 10: DeviceItem dev = Sitecore.Context.Device;
 11: DeviceDefinition device = layout.GetDevice(dev.ID.ToString());
 12:  
 13: // the rendering which you want to check referrings to
 14: Item myrendering = masterdb.Items["/sitecore/layout/renderings/document"];
 15:  
 16: // get the rendering of our item
 17: RenderingDefinition rendering = device.GetRendering(myrendering.ID.ToString());
 18:  
 19: if(rendering != null){
 20: Response.Write(String.Format("Item {0} links to the rendering {1}", item.Name, myrendering.Name));
 21: }
 22: else {
 23: Response.Write(String.Format("Item {0} doesn't link to the rendering {1}", item.Name, myrendering.Name));
 24: }