If you take only the first two years of the ROTC program (Basic Course), there is no military obligation, unless you are a 3- or 4-year scholarship cadet.  In order to progress to the last two years of the program (Advanced Course), you must contract with the United States Army.