A defect action for Wilson loops