Variational problems with free interfaces