Defect modes of a Bose-Einstein condensate in an optical lattice with a localized impurity