There are several Navy options for getting your Master's. As mentioned above, one is VGEP.
Another is to rank high enough in your class to be invited into the "UK program." About 20 Firsties in the program apply for various major scholarships, including Rhodes, Marshall, and possibly a number of other scholarships (there's a long list, and each Mid decides what to try for besides the Rhodes) If you win one and get accepted by Oxford, Cambridge, or another appropriate university in the UK, you would go straight there for your Master's the October after USNA graduation. There's also the possibility of winning a Bowman (sp?) Scholarship for a year of study here in the US.
Another possibility is to be chosen for the Engineering Duty Officer (EDO) program for either SWO or subs. Again, very few people get to do this straight from USNA (max of 10 this year for subs). Not sure of the timing for SWO, but for subs, you'd go through the normal training of about 15 months, then 2-3 years on a boat, then you would do a technical Master's at either the Naval Post Graduate School or MIT (full time duty). After that, you would be obligated to do another 2-3 year tour on a boat. It's also possible to do a lateral transfer into EDO, but I don't know if the Navy pays the freight for your Master's.