The state where you earned the dividends is where you were living when the dividends were paid.
Generally, if you lived in more than one state, you can divide up the dividends by the percent of the year you lived in each state. If you lived in the same state all year, then all of the dividends were earned in that state.