Line and surface defects for the free scalar field