If it happened while carrying dumbbells down by your sides like a farmers walk its probably a strained trap.
Rest it up for a few days, ice it and take ibuprofen (1000-1200 mg is the anti-inflammatory dose needed). Then start doing some light upper back exercises like face pulls/band pull aparts or anything that targets that lower/mid trap region, even when it is still a bit sore.
If it is a bad strain i.e. a slight tear in the muscle belly, you need to increase blood flow to the area (hence the ice and light exercises) and work the muscle as it repairs. If you just leave a tear alone to heal on itself without activity, you could end up with some scar tissue which could be prone to reinjury in that area.
The good news it that it doesn't sound like a "back" injury (as in injury to the spine and surrounding tissues).