The commuter rail does not come to Marshfield. However, Greenbush Station in Scituate, which is the last stop on that commuter line, is about a 5 minute drive to Marshfield. Another option to consider is the commuter bus P & B, which goes from Boston to Plymouth and it makes a couple of stops in Marshfield.
Hope this helps. Please let me know if I can help answer any other questions or if I can help you in your home search.