If a controller clears me for a procedure, and also says "...do not exceed ___ knots", how long does that restriction apply for?
In the U.S., if you are assigned a speed restriction by ATC that restriction remains in place until you are "cleared" for a approach procedure (such as an ILS), receive a "climb via" or "descend via" clearance ( when flying SIDs or STARs), instructed to "resume normal speed" (or similar phraseology such as "delete speed restrictions," etc.) or given a different speed assignment/restriction.
If you are cleared for a procedure, such as an ILS approach, and are instructed to "do not exceed 150 kts" (for example from your question), this speed restriction is to be followed for the duration of the approach unless you are given a different speed assignment or instructed to (something like) "resume normal speed."
Also, keep in mind that if you are instructed to "maintain 270 kts" (for example) while above 10,000 ft (msl) and then instructed to descend below 10,000 ft., you are required to (without having to receive ATC authorization to do so) slow to 250 kts before descending below 10,000 ft. This same requirement (see [14 CFR 91.117]) regarding regulatory speed requirements, also has to be observed by the pilot while flying in other airspace areas that have specific speed requirements.
Additionally, there are circumstances where a published speed restriction is automatically canceled (such as when receiving a vector off of a SID/STAR for some reason).
To have a more complete and comprehensive understanding of the subject of your question, the Aeronautical Information Manual (AIM), section 4-4-12, Speed Adjustments, contains an explanation of the ATC/Pilot requirements pertaining to speed assignments. This would be an important reference for you to read and understand.