As per Census data products, they offer Relationship files that provide a link from ZIP code geography to other Geographies (including State).
Keep in mind, ZIP Code Tabulation Areas (ZCTAs)
ZIP Code Tabulation Areas (ZCTAs) are generalized areal representations of United States Postal Service (USPS) ZIP Code service areas.
The USPS ZIP Codes identify the individual post office or metropolitan area delivery station associated with mailing addresses. USPS ZIP Codes are not areal features but a collection of mail delivery routes.
The 2010 ZIP Code Tabulation Area (ZCTA) Relationship files provide simple relationships between the 2010 ZCTAs and other 2010 Census tabulation geography: counties, county subdivisions, places (incorporated places and census designated places), census tracts, metropolitan and micropolitan statistical areas, New England city and town areas (NECTAs), and congressional districts. From these files, data users may determine which ZCTAs exist within the other geographies and vice versa.
The ZCTA relationship files are nation-based comma-delimited ASCII files and include all 50 states, the District of Columbia, and Puerto Rico.
These files represent intersections of geography only. For instance, for the ZCTA to place relationship file, a unique combination of ZCTA and place FIPS code must exist for a record to be included in the file. Areas where the Census Bureau has delineated a ZCTA, but no place exists, are considered remainder records and are not included in this file. Situations where no ZCTA exists or where there is neither a ZCTA nor a place are also excluded from this file. The same logic applies to all other relationship files. However, data users should be aware that the totals given for the ZCTA or the geographic entity are full totals as published for the 2010 Census, therefore, data users should note that summing the part record totals may not match the totals for the ZCTAs and/or the related entities.
You can view the ZIP code within the State column as a reference.

Also, you can use this A Free Zip Code Database + Latitude and Longitude that provides a download to look up zip codes by state as well.
The Census Bureau also provides an animation ZIP Code Tabulation Areas (ZCTAs) Delineation Animation
"The animation below explains how we used census blocks to create the 2010 ZIP Code Tabulation Areas (ZCTAs)"