Relaxed optimal control problems and applications to shape optimization