Dozens of jobs are set to be cut at a Scottish castle as the tourist attraction is struggling amid projected million-pound losses.